wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes Example of SSLSocket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Example of SSLSocket" Watch "Example of SSLSocket" New topic
Author

Example of SSLSocket

John Landon
Ranch Hand

Joined: Sep 25, 2008
Posts: 227
Hi,
Where I can find an example of usage of SSLSocket with keystore....
Like here but Socket (because I am on client side).
http://stackoverflow.com/questions/867751/ssl-and-socketchannel

Thanks!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

The example with SSLContext and SSLServerSocketFactory can be easily adapted to use a SSLSocketFactory instead of a SSLServerSocketFactory. Using that SSLSocketFactory you can then create (SSL) sockets.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
John Landon
Ranch Hand

Joined: Sep 25, 2008
Posts: 227
Rob Spoor wrote:The example with SSLContext and SSLServerSocketFactory can be easily adapted to use a SSLSocketFactory instead of a SSLServerSocketFactory. Using that SSLSocketFactory you can then create (SSL) sockets.


I figured.. But the problem is that the code does not even compile.
For example: KeyStore keyStore = new KeyStore();
You cannot do because the constructor is protected. You need to do getInstance and I don't know what "type" to provide....

I am looking for some code that has been ran at least.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Example of SSLSocket