How to fix SSL - No available certificate
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.
Roalt
R&D senior developer in aerospace industry (air traffic control, environment). Developer of Open Source track&field meeting organisation software Atdor.com
Updated on July 01, 2022Comments
-
Roalt almost 2 years
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?
-
Bruno over 12 yearsIf it points to an non-existent path, you get a
FileNotFoundException
. "Make sure the -D parameters are set as JVM params" is the most likely explanation: there's no default keystore in JSSE (so not specifying the system property at all leads to this error). -
Roalt over 12 yearsAha! I put the argument in the program arguments and not in the JVM box. Changing that makes everything work! Thank you! (And indeed I already put an absolute path in there before).