Getting java to trust a SSL Certificate
After fixing a few bugs in vimfluence, I tried to connect edit some wiki pages on my personal Confluence wiki which sits behind a self-signed SSL certificate. It works something like:
$ personalwiki HOME Unable to log in to server: https://hub.example.com//rpc/soap-axis/confluenceservice-v1 with user: username. Cause: ; nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target could not close pipe at ./vimfluence line 94.
A bit of an annoyance with Java is that you have to tell Java that it has to implicitly trust a self-signed SSL certificate if you want to connect to it via some jar. In my case I'm using vimfluence to connect to a wiki sitting behind a self-signed SSL certificate. To import the certificate into the keystore, one uses a binary called keytool which brings back strange memories of Actaris's biz.switch documentation from a previous joblet.
(cd /Library/Java/Home/lib/security && sudo keytool -import -keystore cacerts -alias example-wild -file ~admin/example-wild.crt)
One can easily get the SSL certificate by running:
openssl s_client -connect hub.example.com:443