How to fix SSL - No available certificate

11,391

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.

Share:
11,391
Roalt
Author by

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, 2022

Comments

  • Roalt
    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
    Bruno over 12 years
    If 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
    Roalt over 12 years
    Aha! 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).