This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SSLServerSocket  RSS feed

 
vidhya jay
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i would like to know
Difference between ServerSockets and SSLServerSockets....???
both act as same way when keystores are used....

Regards,
vidhya.
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference is that a SSLServerSocket is operating over an SSL connection (ie, it is secure). But you can handle it the same way as you would a ServerSocekt.
 
Catalin Merfu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use the SSL sockets just like normal sockets. You'll need to obtain a SSL certificate and store it in a Java keystore.

try
{
// I store the SSL certificate in PrivateKey.keystore
System.setProperty( "javax.net.ssl.keyStore", "PrivateKey.keystore");
System.setProperty( "javax.net.ssl.keyStorePassword", "password" );

SSLServerSocket server = (SSLServerSocket)
SSLServerSocketFactory.getDefault().createServerSocket( port_ );
while( true )
{
SSLSocket conn = (SSLSocket)server.accept();

Thread clientThread = new Thread(new ConnectionProcessor(conn));
clientThread.start();
}
}
catch( IOException ex )
{
...
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!