Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why SSLServerSocket returns "Cannot recover key"?  RSS feed

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a keystore with a private key and a certificate chain both stored under the alias "MyKeyEntry". When I run SSLServerSocket as:

java -Djavax.net.ssl.keyStore=MyStore.keystore -Djavax.net.ssl.keyStorePassword=mypass MySSLTest

it throws exception:

java.net.SocketException: Default SSL context init failed: Cannot recover key

What am I doing wrong?
 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I discovered the answer and it seems kind of stupid, can anyone explain to me how to change this behavior:

* The password for the keystore was different than the password for the key entry alias (which had the certificate chain in it).

I can't find anywhere that I can specify the alias password in a system property for the SSLServerSocket. (e.g. -Djavax.net.ssl.aliasPassword)

Also, does anyone know where I can get source code for an SSLServerSocket? It's NOT included in Sun's source code (instead they have a stub document with a note saying that because of U.S. regulations about exporting cryptography code, they can't include it)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!