79298767

Date: 2024-12-21 02:13:57
Score: 1
Natty:
Report link

Export the self-signed certificate from the server:

openssl s_client -connect <server>:<port> -showcerts

This will output the certificate details. Copy the section between:

-----BEGIN CERTIFICATE-----

and:

-----END CERTIFICATE-----

(including the BEGIN and END lines)

Save this block to a file, e.g. my-cert.pem.

Then import this file to your Java Keystore:

keytool -import -trustcacerts -alias my-cert -file /path/to/my-cert.pem -keystore <JAVA_HOME>/lib/security/cacerts

Restart your Java application, now it will be able to connect to the server.

You can refer to this article for more details on this procedure: How to Import Self-Signed Certificates into Java Keystore for Local Development.

Reasons:
  • Blacklisted phrase (1): this article
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Olga Strijewski