Creating Certificates for Servers and Individuals
Creating certificates for servers and individuals is very much like creating
a CA; although in the final step you sign the CSR with the CA key instead of
the newly generated key.
# openssl genrsa -des3 -out local.key 1024
# openssl req -new -key local.key -out local.csr
Country Name (2 letter code) []:US
State or Province Name (full name) []:Illinois
Locality Name (eg, city) []:Kankakee
Organization Name (eg, company) []:Widgets Inc
Organizational Unit Name (eg, section) []:Staff
Common Name (eg, fully qualified host name) []:jojo.monkey@widgets.inc
Email Address []:jojo.monkey@widgets.inc
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
# openssl x509 -req -days 365 -in local.csr -CA /etc/ssl/ca.crt \
-CAkey /etc/ssl/private/ca.key -CAcreateserial -out local.crt
The previous example was for an individual, had it been a server then the
Common Name would have been the Fully Qualified Domain Name (FQDN) of
the host, or in some instances the IP address of the machine.
Miscellaneous Commands
Netscape and MSIE use the PKCS format for their certificates. If you are
trying to create certificates for individuals to use then you will need to
change these to PKCS12 format. To make the transition, use
% openssl pkcs12 -export -inkey keyfile -certfile CA-or-Intermediary.crt
-in certfile -out mycert.p12
To convert back, export the certificate from the browser and save it to a
p12 file. Then process it with openssl
% openssl pkcs12 -in p12file -out tempfile
You will be prompted for the passphrase for the .p12 file, then it will
ask for a passphrase to encrypt the key that has been extracted. To
avoid the key being encrypted, add the flag: -nodes
To view the details of the key, use:
# openssl rsa -noout -text -in /etc/ssl/private/ca.key
To view the details of the CSR, use:
# openssl req -noout -text -in /etc/ssl/private/ca.csr
To view the details of the certificate, use:
# openssl x509 -noout -text -in local.crt
To remove the passphrase from a private key:
# openssl rsa -in pass.key -out server.key
To verify a key/certificate pair go together:
# openssl x509 -noout -modulus -in server.crt | openssl md5
openssl rsa -noout -modulus -in myserver.key | openssl md5
Quick and dirty certificate/key pair
# openssl genrsa -out server.key 2048
# openssl req -new -key server.key -out server.csr
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt