1) Download the .crt
file
echo -n | openssl s_client -connect <your domain>:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/<your domain>.crt
replace <your domain>
with your domain (e.g. jossef.com
)
- Apply the .crt
file in Java's cacerts
certificate store
keytool -import -v -trustcacerts -alias <your domain> -file ~/<your domain>.crt -keystore <JAVA HOME>/jre/lib/security/cacerts -keypass changeit -storepass changeit
replace <your domain>
with your domain (e.g. jossef.com
)
replace <JAVA HOME>
with your java home directory
- Hack it
Even though iv'e installed my certificate in Java
's default certificate stores, Tomcat ignores that (seems like it's not configured to use Java's default certificate stores).
To hack this, add the following somewhere in your code:
String certificatesTrustStorePath = "<JAVA HOME>/jre/lib/security/cacerts";System.setProperty("javax.net.ssl.trustStore", certificatesTrustStorePath);