Just a few things I learnt playing with openssl:
Generating a root ca certificate. It’s also a self-signed certificate, so if you want just this, you can stop here:
openssl req -new -x509 -keyout -out -days 365 -extenstions v3_ca
Generating a key and a certificate request:
openssl req -new -nodes -keyout -out
Signing a certificate request:
openssl x509 -req -days 356 -in -out -CA ca3cert.pem -CAkey ca3key.pem -set_serial
Signing a certificate:
openssl x509 -days 356 -in -out -CA ca3cert.pem -CAkey ca3key.pem -set_serial
Now with keytool:
keytool -genkey -keystore -dname
Then we can export certificate signing request:
keytool -certreq -alias mykey -file -keystore
Finally import the certificate:
keytool -import -keystore -file
Exporting certificates for mozilla/ie:
cat > tmp
openssl pkcs12 -export -in tmp out -certfile
Viewing certificate:
openssl x509 -in -text | less
Testing if it works:
openssl s_client -connect localhost:8443 -cert user2cert.pem -key user2key.pem -CAfile ca3cert-1.pem
openssl s_server -connect accept:8443 -cert serverCert.pem -key serverKey.pem -CAfile ca3cert-1.pem
Just a few notes:
1. tomcat uses an alias mykey for a it uses for the websites
2. to import certificates in mozilla/ie you also need to include ca certificate in pkcs12 file.
3. there is a scrpit CA.pl which seem to automate many tasks.
4. Watch out for V3 extensions (certificate purpose, CA=TRUE/FALSE, etc.)
5. Most of these options can be specified directly in opensssl.cnf configuration file.