/usr/lib/ssl/openssl.cnf
.
It is good practice to add -config ./openssl.cnf
to
the commands OpenSSL CA or OpenSSL REQ to ensure that OpenSSL is reading
the correct file.
openssl version -d
$ openssl
Request Certificate
for
|
OpenSSL Command
|
---|---|
CA
|
req -config ./openssl.cnf
-new -out ca.csr -newkey rsa:2048 -keyout cakey.pem -nodes -sha256
|
Server
|
req -config ./openssl.cnf
-new -out server.csr -newkey rsa:2048 -keyout serverkey.pem -sha256
|
Client
|
req -config ./openssl.cnf
-new -out client.csr -newkey rsa:2048 -keyout clientkey.pem -sha256
|
OpenSSL Arguments and
Values
|
Functions
|
---|---|
req
|
Requests a certificate
|
-config ./openssl.cnf
|
Specifies the storage
location for the configuration details for the OpenSSL program
|
-new
|
Identifies the request
as new
|
-out ca.csr
|
Specifies the storage
location for the certificate request
|
-newkey rsa:2048
|
Generates a new private key along with the certificate request that is 2048 bits in
length using the RSA algorithm.
|
-keyout cakey.pem
|
Specifies the storage location for the private key
|
-nodes
|
Prevents the private key from being encrypted
|
-sha256
|
Specifies that the SHA256
hash algorithm be used. Use SHA256 for FIPS 140-2. Without this option,
the default is SHA-1.
|
OpenSSL> req -config ./openssl.cnf -new -out ca.req -newkey rsa:2048 -keyout privkey.pem -nodes Using configuration from ./openssl.cnf Generating a 2048 bit RSA private key ............................++++++ ..........................................++++++ writing new private key to 'cakey.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [US]: State or Province Name (full name) [North Carolina]: Locality Name (city) [Cary]: Organization Name (company) [Proton Inc.]: Organizational Unit Name (department) [IDB]: Common Name (YOUR name) []: proton.com Email Address []:Joe.Bass@proton.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: OpenSSL>
Generate Certificate
for
|
OpenSSL Command
|
---|---|
CA
|
x509 -req -in ca.csr
-signkey cakey.pem -out ca.pem -sha256
Note: This command generates a
self-signed certificate.
|
Server
|
ca -config ./openssl.cnf
-in server.csr -out server.pem -md sha256
Note: This command creates certificates
signed by the CA. These are defined in the openssl.cnf file.
|
Client
|
ca -config ./openssl.cnf
-in client.csr -out client.pem -md sha256
Note: This command creates certificates
signed by the CA. These are defined in the openssl.cnf file.
|
OpenSSL Arguments and
Values
|
Functions
|
---|---|
x509
|
Identifies the certificate
display and signing utility
|
-req
|
Specifies that a certificate
be generated from the request
|
ca
|
Identifies the Certificate
Authority utility
|
-config ./openssl.cnf
|
Specifies the storage
location for the configuration details for the OpenSSL utility
|
-in filename.csr
|
Specifies the storage
location for the input for the certificate request
|
-out filename.pem
|
Specifies the storage
location for the certificate
|
-signkey cakey.pem
|
Specifies the private key that is used to sign the certificate that is generated by
the certificate request
|
-md sha256
|
Specifies that the SHA256
hash algorithm be used. Use SHA256 for FIPS 140-2. Without this option,
the default is SHA-1.
|
Using configuration from ./openssl.cnf
Enter PEM pass phrase: password
Check that the request matches the signature
Signature ok
The Subjects Distinguished Name is as follows
countryName :PRINTABLE:'US'
stateOrProvinceName :PRINTABLE:'NC'
localityName :PRINTABLE:'Cary'
organizationName :PRINTABLE:'Proton, Inc.'
organizationalUnitName:PRINTABLE:'IDB'
commonName :PRINTABLE:'proton.com'
Certificate is to be certified until Oct 16 17:48:27 2014 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries Data Base Updated
openssl rsa -aes256 -in /tmp/cakey.pem -out /tmp/enccakey.pem
openssl> x509 -text -in filename.pem
A digital certificate contains data that was collected to generate the digital certificate
timestamps, a digital signature, and other information. However, because the generated digital certificate is encoded
(usually in PEM format), it is unreadable.
(Your Server Certificate - ssl.crt) -----BEGIN CERTIFICATE----- <PEM encoded certificate> -----END CERTIFICATE----- (Your Intermediate CA Certificate(s)) -----BEGIN CERTIFICATE----- <PEM encoded certificate> -----END CERTIFICATE----- (Your Root CA Certificate) -----BEGIN CERTIFICATE----- <PEM encoded certificate> -----END CERTIFICATE-----
<PEM
encoded certificate>
. The content of each digital
certificate is delimited with a -----BEGIN CERTIFICATE-----
and -----END
CERTIFICATE-----
pair. All text outside the delimiters
is ignored. Therefore, you might not want to use delimited lines for
descriptive comments.
cat server.pem > certchain.pem cat intermediateCA.pem >> certchain.pem cat rootCA.pem >> certchain.pem
openssl x509 -in cert.pem -text -noout openssl x509 -in cert.cer -text -noout openssl x509 -in cert.crt -text -nooutUse the following OpenSSL command to view a DER encoded Certificate:
openssl x509 -in certificate.der -inform der -text -noout
openssl verify -verbose -CAfile <your-CA_file>.pem <your-server-cert>.pemIf your local OpenSSL installation recognizes the certificate or its signing authority and everything checks out (dates, signing chain, and so on.), you get a simple OK message.