Roalt
Roalt

Reputation: 8440

How to fix SSL - No available certificate

I want to make a server SSL socket connection using the following code:

int port = 12000;
ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault();
ServerSocket ssocket = ssocketFactory.createServerSocket(port);

// Listen for connections
Socket socket = ssocket.accept();

I get a "javax.net.ssl.SSLException: No available certificate or key corresponds to the SSL cipher suites which are enabled." when doing the accept.

I created a Keystore that contains a RSA key using:

keytool -genkeypair -alias ClubConnectionCert -keyalg RSA -validity 7 -keystore ClubConnectionKeystore

and I start my Program with the following options:

-Djavax.net.ssl.keyStore=ClubConnectionKeystore -Djavax.net.ssl.keyStorePassword=mypassword 

Do I miss some code to read in the Keystore, or how can I test/debug that the given keystore is actually used?

Upvotes: 8

Views: 11632

Answers (1)

Jean-Philippe Briend
Jean-Philippe Briend

Reputation: 3515

I executed your code and I confirm it's working fine.

Make sure javax.net.ssl.keyStore points exactly to your keystore file. I put my keystore file at the root of my project. Perhaps try absolute path to your keystore.

Make sure the -D parameters are set as JVM params, not Program options (in your IDE).

Good luck, you're about to make it work.

Upvotes: 7

Related Questions