Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix SSL - No available certificate

Tags:

java

ssl

sockets

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?

like image 732
Roalt Avatar asked Dec 16 '11 21:12

Roalt


People also ask

What happens if there is no SSL certificate?

Without SSL, your site visitors and customers are at higher risk of being having their data stolen. Your site security is also at risk without encryption. SSL protects website from phishing scams, data breaches, and many other threats. Ultimately, It builds a secure environment for both visitors and site owners.

How do I enable SSL certificate?

Under Install and Manage SSL for your site (HTTPS), click Manage SSL Sites. Scroll down to the Install an SSL Website and click Browse Certificates. Select the certificate that you want to activate and click Use Certificate. This will auto-fill the fields for the certificate.


1 Answers

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.

like image 138
Jean-Philippe Briend Avatar answered Oct 06 '22 18:10

Jean-Philippe Briend