Creating certificates using the OpenSSL tool
OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer (SSL), and Transport Layer Security (TLS) network protocols and related cryptography standards required by them. The openssl program is a command line tool that provides a rich variety of commands with elaborate options and arguments. The following section lists and explains the openssl commands used for the certificate creation and signing.
To generate a self-signed certificate
Generate a certificate by running the following command:
openssl genrsa -out ca.key 2048Remove the passphrase from the key pair by running the following command:
openssl rsa -in ca.key -out ca.keyGenerate a CSR cerficate by running the following command:
openssl req -x509 -new -key ca.key -out ca.csr -config "[openSSL folder path]\openssl.cnf"Create a self-signed certificate in x509 format by running the following command:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX
To generate server certificate
Generate a certificate by running the following command:
openssl genrsa -out serv.key 2048Generate a CSR certificate by running the following command:
openssl req -new -key serv.key -out serv.csr -config "[openSSL folder path]\openssl.cnf"Generate a signed server certificate by running the following command:
openssl x509 -req -days 730 -in serv.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out serv.crt -extensions v3_req -extfile "[openSSL folder path]\openssl.cnf"
To generate client certificate
Generate a certificate by running the following command:
openssl genrsa -out cli.key 2048Generate a CSR certificate by running the following command:
openssl req -new -key cli.key -out cli.csr -config "[openSSL folder path]\openssl.cnf"Generate a signed client certificate by running the following command:
openssl x509 -req -days 730 -in cli.csr -CA ca.crt -CAkey ca.key -set_serial 02 -out cli.crt -extensions v3_req -extfile "[openSSL folder path]\openssl.cnf"
Related topics