Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/17248ed1a52eab1fb844ba63186dc2c9 to your computer and use it in GitHub Desktop.
Save jrichardsz/17248ed1a52eab1fb844ba63186dc2c9 to your computer and use it in GitHub Desktop.
consume http services with self-signed or rare ssl certificates, selfsigned, cacert

quickly explanation

  • get the certificate of http service using any method
  • load this certificate into your jdk cacert (usually /foo/jdk_home/jre/lib/security/cacerts)
  • point your java code to this cacert
System.setProperty("javax.net.ssl.trustStore", "/foo/jdk_home/jre/lib/security/cacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

challenges

Steps

load this certificate into your jdk cacert

https://stackoverflow.com/questions/4325263/how-to-import-a-cer-certificate-into-a-java-keystore

# linux
keytool -importcert -file certificate.cer -keystore keystore.jks -alias "Alias" 

# windows
keytool -importcert -file D:\foo\bar\acme.cer -keystore C:\foo\bar\openjdk-xyz\jre\lib\security\cacerts -alias "acme service"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment