OpenSSL: demystifying command line parameters
Creating a private key
openssl genrsa -des3 -out priv.key 2048
genrsa generate an RSA private key
-des3 use 3DES cipher to encrypt the key; passphrase is required
-out <filename> output the key to the specified file
[numbits] 2048 the size of the private key to generate in bits; 2048 is the default one but you should consider 4096 key length, see this excellent blog post from Daniel Pocock to learn more
Creating a self signed certificate
This command may be used to generate a test certificate or a self signed root CA.
openssl req -new -x509 -key priv.key -out cert.pem -days 360 -set_serial 123456
req creates and processes certificate requests in PKCS#10 format
-new generates a new certificate request; it will prompt the user for the relevant field values
-x509 outputs a self signed certificate
-key <filename> the file to read the private key from
-out <filename> specifies the output filename
-days <number> the certificate expires after this number of days; default is 30
-set_serial <number> certificate serial number; unless this option is specified, a large random number will be used
Creating a CSR
A certificate signing request (CSR) is a block of encoded text provided to the CA for signing. It contains information that the CA will use to create your certificate.
openssl req -new -key priv.key -out req.csr
Signing a CSR
openssl ca -in req.csr -extensions v3_ca -out newcert.pem
ca can be used to sign certificate requests and generate CRLs; it also maintains a text database of issued certificates and their status
-in <filename> a single certificate request to be signed by the CA
-extensions v3_ca certificate extensions to be added when a certificate is issued; in this case v3
-out <filename> the output file
Bonus: Generating a password with OpenSSL
This command is not required for LIPC-3 but I still find it useful.
openssl rand -base64 32
rand outputs n pseudo-random bytes
-base64 perform base64 encoding on the output
<num> number of bytes to generate
Comments
Post a Comment