I have a jks keystore provided by a CA which is used to sign JARs. However, I would like to host some internal applications over HTTPS and so need to create an SSL certificate so that data can be encrypted over HTTPS. However, in order to avoid untrusted certificate/unknown host warnings in the browser, I was wondering if I could use the jks keystore used to sign JARs to also sign my CSR in order to create an SSL certificate.
So far I have managed to do the following:
Generate a certificate and private key pair using java keytool to create a JKS file, i.e.
keytool -genkeypair -dname "CN=****, OU=****, O=****, L=****, ST=****, C=**" -validity 1000 -alias mykeystore -keypass ***** -keystore mykeystore.jks -storepass *****
*'s above are replaced with actual values
Create a CSR using the java keytool with the JKS from step 1 as input
keytool -certreq -alias mykeystore -file mykeystore_csr.pem -keypass ***** -keystore mykeystore.jks -storepass *****
Convert CA JKS keystore to PKCS using keytool
keytool -importkeystore -srcstoretype jks -srckeystore cakeystore.jks -srcalias caalias -srcstorepass ***** -srckeypass ***** -deststoretype pkcs12 -destkeystore cakeystore.p12 -destalias caalias -deststorepass ***** -destkeypass *****
Convert CA PKCS to PEM using OpenSSL
openssl pkcs12 -in cakeystore.p12 -out cakeystore.pem
Convert CA PEM to CRT using OpenSSL
openssl x509 -outform der -in cakeystore.pem -out cakeystore.crt
At this point I was hoping to be able to use either cakeystore.pem and/or cakeystore.crt to be able to sign mykeystore_csr.pem (from step 2 above) which could then be converted back to JKS to be used as the CA signed SSL certificate
Is this possible? Any ideas or suggesstions would be very appreciated.
Thanks