Search this site


Metadata

Articles

Projects

Presentations

Java JSSE SSLSocket/SSLServerSocket

Holy christ... I've never had so much trouble getting something to work in my life. For the past several hours of scouring google and online book resources I was left without any working means by which to use javax.net.ssl usefully - and by usefully I mean without requiring a pregenerated key certificate, etc. After looking at SSLSocket.getSupportedCipherSuites() and seeing DH_ prefixes on some of the supported ciphers but not on the enabled-by-default ciphers, I looked into what the DH stood for. Turns out it stands for Diffie-Hellman which I knew to be a secret key generation method: My salvation was at hand. For those who are still in the dark, Diffie-Hellman key exchange allows both parties (server and client) to negotiate a secret key across the wire, cancelling my need for a stored, pregenerated key certificate.

Anyhoo, so the past few hours have been totally not awesome. Here's the fix to get SSLSockets to play kosher with eachother without the need for a certificate:

socket.setEnabledCipherSuites(socket.getSupportedCipherSuites());

Do this for both sockets (server AND client) and they will eventually negotiate upon the Diffie-Hellman key exchange, and you can go about your merry way on the happy SSLSocket-land.

I'm so tired :( Want a good example? Here
The SSL Client
The SSL Server (multithreaded)


2 responses to 'Java JSSE SSLSocket/SSLServerSocket'

Showing last 2 comments... (Click here to view all comments)

DangerBunny wrote at Thu Oct 26 10:56:06 2006...
You rock!  I couldn't get this crap to work for anything, and this did it.

Jordan Sissel wrote at Thu Oct 26 11:21:06 2006...
I updated the link to point to the example code again. I forgot to update the link when I migrated my site.

Thanks! :)


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional, if you want me to be able to email you back)
URL (also optional)
Comment: