How-to articles, tricks, and solutions about SSL

Accept server's self-signed ssl certificate in Java client

To accept a server's self-signed SSL certificate in a Java client, you can create a custom javax.net.ssl.X509TrustManager and use it to override the default trust manager.

How to import an existing X.509 certificate and private key in Java keystore to use in SSL?

To import an existing X.509 certificate and private key into a Java keystore, you can use the keytool utility that is included with the Java Development Kit (JDK).

Java HTTPS client certificate authentication

To perform HTTPS client certificate authentication in Java, you can use the HttpsURLConnection class and the SSLSocketFactory class.

pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)"

This error message occurs when pip is unable to verify the certificate of the website it is trying to connect to.

Python Requests throwing SSLError

Here's a code snippet that demonstrates how to use the Python requests library to make a GET request to a URL, while handling a possible SSLError:

Received fatal alert: handshake_failure through SSLHandshakeException

Received fatal alert: handshake_failure is an error message that can occur during an SSL/TLS handshake.

Setting up SSL on a local xampp/apache server

To set up SSL on a local XAMPP/Apache server, you will need to generate a self-signed certificate, configure the Apache server to use the certificate, and then access the server using https.

Trusting all certificates using HttpClient over HTTPS

To trust all certificates when using the Apache HttpClient library to make HTTPS requests, you can create a custom X509TrustManager implementation that trusts all certificates and use it to create an SSLContext with a custom TrustStrategy.

Unable to find valid certification path to requested target - error even after cert imported

If you are getting the "unable to find valid certification path to requested target" error even after importing the certificate, there are a few possible causes and solutions:<br>

Use cURL with SNI (Server Name Indication)

Server Name Indication (SNI) is an extension to the Transport Layer Security (TLS) protocol that allows a client to specify the hostname it is trying to connect to at the start of the handshaking process.

Warning about SSL connection when connecting to MySQL database

If you are getting a warning about an SSL connection when connecting to a MySQL database, it may be because you are using an older version of the MySQL client library that does not support SSL connections by default.