Extract cert and private key from JKS keystore to use it in Apache2 httpd

Posted by momo on Server Fault See other posts from Server Fault or by momo
Published on 2012-10-09T08:53:44Z Indexed on 2012/10/09 9:40 UTC
Read the original article Hit count: 422

I tried to find this but no luck. I created a JKS keystore and generated a CSR, then imported the signed cert and intermediate and root CA certs. Used this keystore on Tomcat without problems.

Now I want to use the same cert for Apache2 http server on the same machine. I actually want to set up mod_jk to redirect /*.jsp and servlets paths to Tomcat and serve the static content and PHP from Apache2.

I tried to convert JKS to PKCS12 with keytool to afterwards handle it with openssl with a command like this:

keytool -importkeystore -srckeystore foo.jks \
   -destkeystore foo.p12 \
   -srcstoretype jks \
   -deststoretype pkcs12

The problem is only the cert is exported but not the rest of the chain. I actually used this keystore on Apache and it complained about key and cert don't matching (not sure if it's related to the chain or not).

Can anyone point me on the right direction? I am not a server guy and I am kinda lost with all this things :-(

© Server Fault or respective owner

Related posts about apache2

Related posts about tomcat