Pki Tutorial
Pki Tutorial
Pki Tutorial
Release v1.1
Stefan H. Holek
1 Overview 3
2 PKI Concepts 5
3 Examples 9
4 Appendices 67
5 References 71
i
ii
OpenSSL PKI Tutorial, Release v1.1
Contents 1
OpenSSL PKI Tutorial, Release v1.1
2 Contents
CHAPTER 1
Overview
This tutorial shows how to implement real-world PKIs with the OpenSSL toolkit.
In the first part of the tutorial we introduce the necessary terms and concepts. The second part consists of examples,
where we build increasingly more sophisticated PKIs using nothing but the openssl utility. The tutorial puts a
special focus on configuration files, which are key to taming the openssl command line. It also serves to promote
what we have found to be the most effective way of partinioning the configuration space:
• One configuration file per CA, and
• One configuration file per CSR type.
Please study the configuration files included in the examples, it’s where most of the treasure is buried.
3
OpenSSL PKI Tutorial, Release v1.1
4 Chapter 1. Overview
CHAPTER 2
PKI Concepts
At its heart, an X.509 PKI is a security architecture that uses well-established cryptographic mechanisms to support
use-cases like email protection and web server authentication. In this regard it is similar to other systems based on
public-key cryptography, for example OpenPGP [RFC 4880]. In the realm of X.509 however, and thanks to its roots in
a globe-spanning scheme devised by the telecom industry, these mechanisms come with a fair amount of administrative
overhead.
One thing to keep in mind is that X.509 is not an application, but a specification upon which applications like Secure
Multipurpose Internet Mail Extensions (S/MIME) and Transport Layer Security (TLS) are based. The building blocks
are very generic and derive most of their meaning from the relations that exist/are established between them. It’s called
an infrastructure for a reason.
5
OpenSSL PKI Tutorial, Release v1.1
Process
Components
Public Key Infrastructure (PKI) Security architecture where trust is conveyed through the signature of a trusted
CA.
Certificate Authority (CA) Entity issuing certificates and CRLs.
Registration Authority (RA) Entity handling PKI enrollment. May be identical with the CA.
Certificate Public key and ID bound by a CA signature.
Certificate Signing Request (CSR) Request for certification. Contains public key and ID to be certified.
Certificate Revocation List (CRL) List of revoked certificates. Issued by a CA at regular intervals.
Certification Practice Statement (CPS) Document describing structure and processes of a CA.
CA Types
Certificate Types
File Formats
Privacy Enhanced Mail (PEM) Text format. Base-64 encoded data with header and footer lines. Preferred format
in OpenSSL and most software based on it (e.g. Apache mod_ssl, stunnel).
Distinguished Encoding Rules (DER) Binary format. Preferred format in Windows environments. Also the official
format for Internet download of certificates and CRLs.
1 The RFC classifies any CA-signs-CA scenario as cross-certification, to distinguish it from self-issuing. Outside of specs however, the term
Examples
The examples are meant to be done in order, each providing the basis for the ones that follow. They are deliberately
low on prose, we prefer to let the configuration files and command lines speak for themselves.
You will find a reference section at the bottom of each page, with links to relevant parts of the OpenSSL documentation.
Please use the links for details on command line options and configuration file settings.
Note: You need at least OpenSSL 1.0.1. Check with:
openssl version
Simple PKI
In this example we create the simplest possible PKI: One root CA and one signing CA. We use the CA to issue two
types of user certificates.
Simple PKI
The Simple PKI consists of one root CA and one signing CA.
Overview
We assume an organisation named Simple Inc, controlling the domain simple.org. The organisation runs a small PKI
to secure its email and intranet traffic.
9
OpenSSL PKI Tutorial, Release v1.1
To construct the PKI, we first create the Simple Root CA and its CA certificate. We then use the root CA to create the
Simple Signing CA. Once the CAs are in place, we issue an email-protection certificate to employee Fred Flintstone
and a TLS-server certificate to the webserver at www.simple.org. Finally, we look at the output formats the CA needs
to support and show how to view the contents of files we have created.
All commands are ready to be copy/pasted into a terminal session. When you have reached the end of this page, you
will have performed all operations you are likely to encounter in a PKI.
To get started, fetch the Simple PKI example files and change into the new directory:
Configuration Files
# Simple Root CA
# The [default] section contains global constants that can be referred to from
# the entire configuration file. It may also hold settings pertaining to more
# than one openssl command.
[ default ]
ca = root-ca # CA name
dir = . # Top dir
10 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
# The next part of the configuration file is used by the openssl req command.
# It defines the CA's key pair, its DN, and the desired extensions for the CA
# certificate.
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
0.domainComponent = "org"
1.domainComponent = "simple"
organizationName = "Simple Inc"
organizationalUnitName = "Simple Root CA"
commonName = "Simple Root CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
[ ca ]
default_ca = root_ca # The default CA section
[ root_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
serial = $dir/ca/$ca/db/$ca.crt.srl # Serial number file
crlnumber = $dir/ca/$ca/db/$ca.crl.srl # CRL number file
database = $dir/ca/$ca/db/$ca.db # Index file
unique_subject = no # Require unique subject
default_days = 3652 # How long to certify for
default_md = sha1 # MD to use
policy = match_pol # Default naming policy
email_in_dn = no # Add email to cert DN
preserve = no # Keep passed DN ordering
name_opt = ca_default # Subject DN display options
cert_opt = ca_default # Certificate display options
copy_extensions = none # Copy extensions from CSR
x509_extensions = signing_ca_ext # Default cert extensions
default_crl_days = 365 # How long before next CRL
crl_extensions = crl_ext # CRL extensions
[ match_pol ]
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
[ root_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
[ signing_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
# CRL extensions exist solely to point to the CA certificate that has issued
# the CRL.
[ crl_ext ]
authorityKeyIdentifier = keyid:always
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
# Simple Signing CA
# The [default] section contains global constants that can be referred to from
# the entire configuration file. It may also hold settings pertaining to more
# than one openssl command.
[ default ]
12 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
ca = signing-ca # CA name
dir = . # Top dir
# The next part of the configuration file is used by the openssl req command.
# It defines the CA's key pair, its DN, and the desired extensions for the CA
# certificate.
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
0.domainComponent = "org"
1.domainComponent = "simple"
organizationName = "Simple Inc"
organizationalUnitName = "Simple Signing CA"
commonName = "Simple Signing CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
[ ca ]
default_ca = signing_ca # The default CA section
[ signing_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
serial = $dir/ca/$ca/db/$ca.crt.srl # Serial number file
crlnumber = $dir/ca/$ca/db/$ca.crl.srl # CRL number file
database = $dir/ca/$ca/db/$ca.db # Index file
unique_subject = no # Require unique subject
default_days = 730 # How long to certify for
default_md = sha1 # MD to use
policy = match_pol # Default naming policy
email_in_dn = no # Add email to cert DN
preserve = no # Keep passed DN ordering
name_opt = ca_default # Subject DN display options
cert_opt = ca_default # Certificate display options
copy_extensions = copy # Copy extensions from CSR
x509_extensions = email_ext # Default cert extensions
default_crl_days = 7 # How long before next CRL
crl_extensions = crl_ext # CRL extensions
[ match_pol ]
domainComponent = match # Must match 'simple.org'
organizationName = match # Must match 'Simple Inc'
organizationalUnitName = optional # Included if present
commonName = supplied # Must be present
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
[ email_ext ]
keyUsage = critical,digitalSignature,keyEncipherment
basicConstraints = CA:false
extendedKeyUsage = emailProtection,clientAuth
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
[ server_ext ]
keyUsage = critical,digitalSignature,keyEncipherment
basicConstraints = CA:false
extendedKeyUsage = serverAuth,clientAuth
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
# CRL extensions exist solely to point to the CA certificate that has issued
# the CRL.
[ crl_ext ]
authorityKeyIdentifier = keyid:always
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
And one configuration file per CSR type:
14 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
# This file is used by the openssl req command. Since we cannot know the DN in
# advance the user is prompted for DN information.
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = email_dn # DN template
req_extensions = email_reqext # Desired extensions
[ email_dn ]
0.domainComponent = "1. Domain Component (eg, com) "
1.domainComponent = "2. Domain Component (eg, company) "
2.domainComponent = "3. Domain Component (eg, pki) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
emailAddress = "7. Email Address (eg, name@fqdn)"
emailAddress_max = 40
[ email_reqext ]
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = emailProtection,clientAuth
subjectKeyIdentifier = hash
subjectAltName = email:move
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
# This file is used by the openssl req command. The subjectAltName cannot be
# prompted for and must be specified in the SAN environment variable.
[ default ]
SAN = DNS:yourdomain.tld # Default value
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = no # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
[ server_dn ]
0.domainComponent = "1. Domain Component (eg, com) "
1.domainComponent = "2. Domain Component (eg, company) "
2.domainComponent = "3. Domain Component (eg, pki) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, FQDN) "
commonName_max = 64
[ server_reqext ]
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = serverAuth,clientAuth
subjectKeyIdentifier = hash
subjectAltName = $ENV::SAN
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
Please familiarize yourself with the configuration files before you continue.
1. Create Root CA
The ca directory holds CA resources, the crl directory holds CRLs, and the certs directory holds user certificates.
cp /dev/null ca/root-ca/db/root-ca.db
cp /dev/null ca/root-ca/db/root-ca.db.attr
echo 01 > ca/root-ca/db/root-ca.crt.srl
echo 01 > ca/root-ca/db/root-ca.crl.srl
The database files must exist before the openssl ca command can be used. The file contents are described in
Appendix B: CA Database.
16 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
With the openssl req -new command we create a private key and a certificate signing request (CSR) for the
root CA. You will be asked for a passphrase to protect the private key. The openssl req command takes its
configuration from the [req] section of the configuration file.
openssl ca -selfsign \
-config etc/root-ca.conf \
-in ca/root-ca.csr \
-out ca/root-ca.crt \
-extensions root_ca_ext
With the openssl ca command we issue a root CA certificate based on the CSR. The root certificate is self-
signed and serves as the starting point for all trust relationships in the PKI. The openssl ca command takes its
configuration from the [ca] section of the configuration file.
2. Create Signing CA
The ca directory holds CA resources, the crl directory holds CRLs, and the certs directory holds user certificates.
We will use this layout for all CAs in this tutorial.
cp /dev/null ca/signing-ca/db/signing-ca.db
cp /dev/null ca/signing-ca/db/signing-ca.db.attr
echo 01 > ca/signing-ca/db/signing-ca.crt.srl
echo 01 > ca/signing-ca/db/signing-ca.crl.srl
With the openssl req -new command we create a private key and a CSR for the signing CA. You will be asked
for a passphrase to protect the private key. The openssl req command takes its configuration from the [req] section
of the configuration file.
openssl ca \
-config etc/root-ca.conf \
-in ca/signing-ca.csr \
-out ca/signing-ca.crt \
-extensions signing_ca_ext
With the openssl ca command we issue a certificate based on the CSR. The command takes its configuration from
the [ca] section of the configuration file. Note that it is the root CA that issues the signing CA certificate! Note also
that we attach a different set of extensions.
3. Operate Signing CA
With the openssl req -new command we create the private key and CSR for an email-protection certificate.
We use a request configuration file specifically prepared for the task. When prompted enter these DN components:
DC=org, DC=simple, O=Simple Inc, CN=Fred Flintstone, emailAddress=fred@simple.org. Leave other fields empty.
openssl ca \
-config etc/signing-ca.conf \
-in certs/fred.csr \
-out certs/fred.crt \
-extensions email_ext
We use the signing CA to issue the email-protection certificate. The certificate type is defined by the extensions we
attach. A copy of the certificate is saved in the certificate archive under the name ca/signing-ca/01.pem (01
being the certificate serial number in hex.)
SAN=DNS:www.simple.org \
openssl req -new \
-config etc/server.conf \
-out certs/simple.org.csr \
-keyout certs/simple.org.key
Next we create the private key and CSR for a TLS-server certificate using another request configuration file. When
prompted enter these DN components: DC=org, DC=simple, O=Simple Inc, CN=www.simple.org. Note that the
subjectAltName must be specified as environment variable. Note also that server keys typically have no passphrase.
18 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl ca \
-config etc/signing-ca.conf \
-in certs/simple.org.csr \
-out certs/simple.org.crt \
-extensions server_ext
We use the signing CA to issue the server certificate. The certificate type is defined by the extensions we attach. A
copy of the certificate is saved in the certificate archive under the name ca/signing-ca/02.pem.
openssl ca \
-config etc/signing-ca.conf \
-revoke ca/signing-ca/01.pem \
-crl_reason superseded
Certain events, like certificate replacement or loss of private key, require a certificate to be revoked before its scheduled
expiration date. The openssl ca -revoke command marks a certificate as revoked in the CA database. It will
from then on be included in CRLs issued by the CA. The above command revokes the certificate with serial number
01 (hex).
openssl ca -gencrl \
-config etc/signing-ca.conf \
-out crl/signing-ca.crl
The openssl ca -gencrl command creates a certificate revocation list (CRL). The CRL contains all revoked,
not-yet-expired certificates from the CA database. A new CRL must be issued at regular intervals.
4. Output Formats
openssl x509 \
-in certs/fred.crt \
-out certs/fred.cer \
-outform der
All published certificates must be in DER format [RFC 2585#section-3]. Also see Appendix A: MIME Types.
openssl crl \
-in crl/signing-ca.crl \
-out crl/signing-ca.crl \
-outform der
All published CRLs must be in DER format [RFC 2585#section-3]. Also see Appendix A: MIME Types.
PKCS#7 is used to bundle two or more certificates. The format would also allow for CRLs but they are not used in
practice.
PKCS#12 is used to bundle a certificate and its private key. Additional certificates may be added, typically the certifi-
cates comprising the chain up to the Root CA.
PEM bundles are created by concatenating other PEM-formatted files. The most common forms are “cert chain”, “key
+ cert”, and “key + cert chain”. PEM bundles are supported by OpenSSL and most software based on it (e.g. Apache
mod_ssl and stunnel.)
5. View Results
openssl req \
-in certs/fred.csr \
-noout \
-text
The openssl req command can be used to display the contents of CSR files. The -noout and -text options
select a human-readable output format.
20 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl x509 \
-in certs/fred.crt \
-noout \
-text
The openssl x509 command can be used to display the contents of certificate files. The -noout and -text
options have the same purpose as before.
openssl crl \
-in crl/signing-ca.crl \
-inform der \
-noout \
-text
The openssl crl command can be used to view the contents of CRL files. Note that we specify -inform der
because we have already converted the CRL in step 4.2.
openssl pkcs7 \
-in ca/signing-ca-chain.p7c \
-inform der \
-noout \
-text \
-print_certs
The openssl pkcs7 command can be used to display the contents of PKCS#7 bundles.
openssl pkcs12 \
-in certs/fred.p12 \
-nodes \
-info
The openssl pkcs12 command can be used to display the contents of PKCS#12 bundles.
References
• http://www.openssl.org/docs/apps/req.html
• http://www.openssl.org/docs/apps/ca.html
• http://www.openssl.org/docs/apps/x509.html
• http://www.openssl.org/docs/apps/crl.html
• http://www.openssl.org/docs/apps/crl2pkcs7.html
• http://www.openssl.org/docs/apps/pkcs7.html
• http://www.openssl.org/docs/apps/pkcs12.html
Advanced PKI
In this example we create a larger setup, consisting of a root CA and three signing CAs. We use the CAs to issue
4 different types of user certificates. We also encounter two new certificate extensions: authorityInfoAccess and
crlDistributionPoints.
Advanced PKI
Overview
We assume a company named Green AS, controlling the domain green.no. The company runs a three-pronged PKI to
serve its security needs.
To implement the PKI, we first create the Green Root CA and its CA certificate. We then use the root CA to create
the three signing CAs: Green Email CA, Green TLS CA, and Green Software CA. The CAs in place we proceed to
show them in operation, issuing user certificates for email-protection, TLS-authentication, and code-signing purposes
respectively.
22 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
All commands are ready to be copy/pasted into a terminal session. When you have reached the end of this page, you
will have built a PKI with multiple signing CAs and issued 4 different types of user certificates.
To get started, fetch the Advanced PKI example files and change into the new directory:
git clone https://bitbucket.org/stefanholek/pki-example-2
cd pki-example-2
Configuration Files
# Green Root CA
[ default ]
ca = root-ca # CA name
dir = . # Top dir
base_url = http://green.no/ca # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
name_opt = multiline,-esc_msb,utf8 # Display UTF-8 characters
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "NO"
organizationName = "Green AS"
organizationalUnitName = "Green Certificate Authority"
commonName = "Green Root CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = root_ca # The default CA section
[ root_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
[ match_pol ]
countryName = match # Must match 'NO'
stateOrProvinceName = optional # Included if present
localityName = optional # Included if present
organizationName = match # Must match 'Green AS'
organizationalUnitName = optional # Included if present
commonName = supplied # Must be present
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ root_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
[ signing_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
[ crl_ext ]
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
24 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
URI.0 = $crl_url
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
# Green Email CA
[ default ]
ca = email-ca # CA name
dir = . # Top dir
base_url = http://green.no/ca # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
name_opt = multiline,-esc_msb,utf8 # Display UTF-8 characters
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "NO"
organizationName = "Green AS"
organizationalUnitName = "Green Certificate Authority"
commonName = "Green Email CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = email_ca # The default CA section
[ email_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
[ match_pol ]
countryName = match # Must match 'NO'
stateOrProvinceName = optional # Included if present
localityName = optional # Included if present
organizationName = match # Must match 'Green AS'
organizationalUnitName = optional # Included if present
commonName = supplied # Must be present
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ email_ext ]
keyUsage = critical,digitalSignature,keyEncipherment
basicConstraints = CA:false
extendedKeyUsage = emailProtection,clientAuth,anyExtendedKeyUsage
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
[ crl_ext ]
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
URI.0 = $crl_url
26 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
# Green TLS CA
[ default ]
ca = tls-ca # CA name
dir = . # Top dir
base_url = http://green.no/ca # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
name_opt = multiline,-esc_msb,utf8 # Display UTF-8 characters
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "NO"
organizationName = "Green AS"
organizationalUnitName = "Green Certificate Authority"
commonName = "Green TLS CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = tls_ca # The default CA section
[ tls_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
serial = $dir/ca/$ca/db/$ca.crt.srl # Serial number file
crlnumber = $dir/ca/$ca/db/$ca.crl.srl # CRL number file
[ match_pol ]
countryName = match # Must match 'NO'
stateOrProvinceName = optional # Included if present
localityName = optional # Included if present
organizationName = match # Must match 'Green AS'
organizationalUnitName = optional # Included if present
commonName = supplied # Must be present
[ extern_pol ]
countryName = supplied # Must be present
stateOrProvinceName = optional # Included if present
localityName = optional # Included if present
organizationName = supplied # Must be present
organizationalUnitName = optional # Included if present
commonName = supplied # Must be present
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ server_ext ]
keyUsage = critical,digitalSignature,keyEncipherment
basicConstraints = CA:false
extendedKeyUsage = serverAuth,clientAuth
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
[ client_ext ]
keyUsage = critical,digitalSignature
basicConstraints = CA:false
extendedKeyUsage = clientAuth
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
28 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
crlDistributionPoints = @crl_info
[ crl_ext ]
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
URI.0 = $crl_url
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
# Green Software CA
[ default ]
ca = software-ca # CA name
dir = . # Top dir
base_url = http://green.no/ca # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
name_opt = multiline,-esc_msb,utf8 # Display UTF-8 characters
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "NO"
organizationName = "Green AS"
organizationalUnitName = "Green Certificate Authority"
commonName = "Green Software CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = software_ca # The default CA section
[ software_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
serial = $dir/ca/$ca/db/$ca.crt.srl # Serial number file
crlnumber = $dir/ca/$ca/db/$ca.crl.srl # CRL number file
database = $dir/ca/$ca/db/$ca.db # Index file
unique_subject = no # Require unique subject
default_days = 1826 # How long to certify for
default_md = sha1 # MD to use
policy = match_pol # Default naming policy
email_in_dn = no # Add email to cert DN
preserve = no # Keep passed DN ordering
name_opt = $name_opt # Subject DN display options
cert_opt = ca_default # Certificate display options
copy_extensions = copy # Copy extensions from CSR
x509_extensions = codesign_ext # Default cert extensions
default_crl_days = 30 # How long before next CRL
crl_extensions = crl_ext # CRL extensions
[ match_pol ]
countryName = match # Must match 'NO'
stateOrProvinceName = optional # Included if present
localityName = optional # Included if present
organizationName = match # Must match 'Green AS'
organizationalUnitName = optional # Included if present
commonName = supplied # Must be present
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ codesign_ext ]
keyUsage = critical,digitalSignature
basicConstraints = CA:false
extendedKeyUsage = critical,codeSigning
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
[ crl_ext ]
30 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
URI.0 = $crl_url
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
And one configuration file per CSR type:
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = email_dn # DN template
req_extensions = email_reqext # Desired extensions
[ email_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
emailAddress = "7. Email Address (eg, name@fqdn)"
emailAddress_max = 40
[ email_reqext ]
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = emailProtection,clientAuth
subjectKeyIdentifier = hash
subjectAltName = email:move
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
[ default ]
SAN = DNS:yourdomain.tld # Default value
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = no # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = server_dn # DN template
req_extensions = server_reqext # Desired extensions
[ server_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, FQDN) "
commonName_max = 64
[ server_reqext ]
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = serverAuth,clientAuth
subjectKeyIdentifier = hash
subjectAltName = $ENV::SAN
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
[ req ]
32 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
[ client_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
emailAddress = "7. Email Address (eg, name@fqdn)"
emailAddress_max = 40
[ client_reqext ]
keyUsage = critical,digitalSignature
extendedKeyUsage = clientAuth
subjectKeyIdentifier = hash
subjectAltName = email:move
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = codesign_dn # DN template
req_extensions = codesign_reqext # Desired extensions
[ codesign_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
[ codesign_reqext ]
keyUsage = critical,digitalSignature
extendedKeyUsage = critical,codeSigning
subjectKeyIdentifier = hash
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
Please study the configuration files before you continue.
1. Create Root CA
The ca directory holds CA resources, the crl directory holds CRLs, and the certs directory holds user certificates.
The directory layout stays the same throughout the tutorial.
cp /dev/null ca/root-ca/db/root-ca.db
cp /dev/null ca/root-ca/db/root-ca.db.attr
echo 01 > ca/root-ca/db/root-ca.crt.srl
echo 01 > ca/root-ca/db/root-ca.crl.srl
The files must exist before the openssl ca command can be used. Also see Appendix B: CA Database.
With the openssl req -new command we create a private key and a CSR for the root CA. The configuration is
taken from the [req] section of the root CA configuration file.
34 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl ca -selfsign \
-config etc/root-ca.conf \
-in ca/root-ca.csr \
-out ca/root-ca.crt \
-extensions root_ca_ext \
-enddate 20301231235959Z
With the openssl ca command we create a self-signed root certificate from the CSR. The configuration is taken
from the [ca] section of the root CA configuration file. Note that we specify an end date based on the key length.
2048-bit RSA keys are deemed safe until 2030 (RSA Labs).
openssl ca -gencrl \
-config etc/root-ca.conf \
-out crl/root-ca.crl
2. Create Email CA
cp /dev/null ca/email-ca/db/email-ca.db
cp /dev/null ca/email-ca/db/email-ca.db.attr
echo 01 > ca/email-ca/db/email-ca.crt.srl
echo 01 > ca/email-ca/db/email-ca.crl.srl
We create a private key and a CSR for the email CA. The configuration is taken from the [req] section of the email CA
configuration file.
openssl ca \
-config etc/root-ca.conf \
-in ca/email-ca.csr \
-out ca/email-ca.crt \
-extensions signing_ca_ext
We use the root CA to issue the email CA certificate. Points if you noticed that -extensions could have been omitted.
openssl ca -gencrl \
-config etc/email-ca.conf \
-out crl/email-ca.crl
We create a certificate chain file from the email CA and root CA certificates. It will come handly later as input for the
openssl pkcs12 command.
3. Create TLS CA
cp /dev/null ca/tls-ca/db/tls-ca.db
cp /dev/null ca/tls-ca/db/tls-ca.db.attr
echo 01 > ca/tls-ca/db/tls-ca.crt.srl
echo 01 > ca/tls-ca/db/tls-ca.crl.srl
36 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
We create a private key and a CSR for the TLS CA. The configuration is taken from the [req] section of the TLS CA
configuration file.
openssl ca \
-config etc/root-ca.conf \
-in ca/tls-ca.csr \
-out ca/tls-ca.crt \
-extensions signing_ca_ext
openssl ca -gencrl \
-config etc/tls-ca.conf \
-out crl/tls-ca.crl
4. Create Software CA
cp /dev/null ca/software-ca/db/software-ca.db
cp /dev/null ca/software-ca/db/software-ca.db.attr
echo 01 > ca/software-ca/db/software-ca.crt.srl
echo 01 > ca/software-ca/db/software-ca.crl.srl
We create a private key and a CSR for the software CA. The configuration is taken from the [req] section of the
software CA configuration file.
openssl ca \
-config etc/root-ca.conf \
-in ca/software-ca.csr \
-out ca/software-ca.crt \
-extensions signing_ca_ext
openssl ca -gencrl \
-config etc/software-ca.conf \
-out crl/software-ca.crl
5. Operate Email CA
We create the private key and CSR for an email-protection certificate using a request configuration file. When prompted
enter these DN components: C=NO, O=Green AS, CN=Fred Flintstone, emailAddress=fred@green.no. Leave other
fields empty.
38 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl ca \
-config etc/email-ca.conf \
-in certs/fred.csr \
-out certs/fred.crt \
-extensions email_ext
We use the email CA to issue Fred’s email-protection certificate. A copy of the certificate is saved in the certificate
archive under the name ca/email-ca/01.pem (01 being the certificate serial number in hex.)
We pack the private key, the certificate, and the CA chain into a PKCS#12 bundle. This format (often with a .pfx ex-
tension) is used to distribute keys and certificates to end users. The friendly names help identify individual certificates
within the bundle.
openssl ca \
-config etc/email-ca.conf \
-revoke ca/email-ca/01.pem \
-crl_reason keyCompromise
openssl ca -gencrl \
-config etc/email-ca.conf \
-out crl/email-ca.crl
6. Operate TLS CA
SAN=DNS:green.no,DNS:www.green.no \
openssl req -new \
-config etc/server.conf \
-out certs/green.no.csr \
-keyout certs/green.no.key
We create the private key and CSR for a TLS-server certificate using the appropriate request configuration file. When
prompted enter these DN components: C=NO, O=Green AS, CN=www.green.no. The subjectAltName cannot be
prompted for and must be specified as environment variable.
openssl ca \
-config etc/tls-ca.conf \
-in certs/green.no.csr \
-out certs/green.no.crt \
-extensions server_ext
We pack the private key, the certificate, and the CA chain into a PKCS#12 bundle for distribution.
We create the private key and CSR for a TLS-client certificate using the client request configuration file. When
prompted enter these DN components: C=NO, O=Telenor AS, OU=Support, CN=Barney Rubble, emailAd-
dress=barney@telenor.no.
openssl ca \
-config etc/tls-ca.conf \
-in certs/barney.csr \
-out certs/barney.crt \
-policy extern_pol \
-extensions client_ext
40 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
We use the TLS CA to issue Barney’s client certificate. Note that we must specify the ‘extern’ naming policy because
the DN would not satisfy the default ‘match’ policy.
openssl ca \
-config etc/tls-ca.conf \
-revoke ca/tls-ca/02.pem \
-crl_reason affiliationChanged
openssl ca -gencrl \
-config etc/tls-ca.conf \
-out crl/tls-ca.crl
7. Operate Software CA
We create the private key and CSR for a code-signing certificate using another request configuration file. When
prompted enter these DN components: C=NO, O=Green AS, OU=Green Certificate Authority, CN=Green Software
Certificate.
openssl ca \
-config etc/software-ca.conf \
-in certs/software.csr \
-out certs/software.crt \
-extensions codesign_ext
openssl ca \
-config etc/software-ca.conf \
-revoke ca/software-ca/01.pem \
-crl_reason unspecified
openssl ca -gencrl \
-config etc/software-ca.conf \
-out crl/software-ca.crl
8. Publish Certificates
openssl x509 \
-in ca/root-ca.crt \
-out ca/root-ca.cer \
-outform der
All published certificates must be in DER format. MIME type: application/pkix-cert. [RFC 2585#section-4.1]
42 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl crl \
-in crl/email-ca.crl \
-out crl/email-ca.crl \
-outform der
All published CRLs must be in DER format. MIME type: application/pkix-crl. [RFC 2585#section-4.2]
PKCS#7 is used to bundle two or more certificates. MIME type: application/pkcs7-mime. [RFC 5273#page-3]
References
• http://www.openssl.org/docs/apps/req.html
• http://www.openssl.org/docs/apps/ca.html
• http://www.openssl.org/docs/apps/x509.html
• http://www.openssl.org/docs/apps/crl.html
• http://www.openssl.org/docs/apps/crl2pkcs7.html
• http://www.openssl.org/docs/apps/pkcs7.html
• http://www.openssl.org/docs/apps/pkcs12.html
Expert PKI
In this example we create a 3-tier CA hierarchy: One root CA, one intermediate CA, and two signing CAs. We use
the CAs to issue 6 types of user certificates. We introduce certificate policies and the certificatePolicies extension. We
also show how to configure an OCSP responder.
Expert PKI
The Expert PKI consist of a root CA, an intermediate CA, and two signing CAs.
Overview
We assume a company named Blue AB, controlling the domain blue.se. The company operates a flexible, multi-level
PKI.
To construct the PKI, we start with the Blue Root CA followed by the intermediate Blue Network CA. We then use
the Network CA to create the two signing CAs: Blue Identity CA and Blue Component CA. With the CAs in place,
we proceed to issue certificates to users and network components respectively.
All commands are ready to be copy/pasted into a terminal session. When you have reached the end of this page, you
will have built a PKI with both intermediate and signing CAs and issued all major types of user certificates.
To get started, fetch the Expert PKI example files and change into the new directory:
Configuration Files
# Blue Root CA
[ default ]
ca = root-ca # CA name
dir = . # Top dir
base_url = http://pki.blue.se # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
44 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "SE"
organizationName = "Blue AB"
organizationalUnitName = "Blue Root CA"
commonName = "Blue Root CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = root_ca # The default CA section
[ root_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
serial = $dir/ca/$ca/db/$ca.crt.srl # Serial number file
crlnumber = $dir/ca/$ca/db/$ca.crl.srl # CRL number file
database = $dir/ca/$ca/db/$ca.db # Index file
unique_subject = no # Require unique subject
default_days = 3652 # How long to certify for
default_md = sha1 # MD to use
policy = match_pol # Default naming policy
email_in_dn = no # Add email to cert DN
preserve = no # Keep passed DN ordering
name_opt = $name_opt # Subject DN display options
cert_opt = ca_default # Certificate display options
copy_extensions = none # Copy extensions from CSR
x509_extensions = intermediate_ca_ext # Default cert extensions
default_crl_days = 30 # How long before next CRL
crl_extensions = crl_ext # CRL extensions
[ match_pol ]
countryName = match
stateOrProvinceName = optional
localityName = optional
organizationName = match
organizationalUnitName = optional
commonName = supplied
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ root_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
[ intermediate_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumAssurance,blueMediumDevice
[ crl_ext ]
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
URI.0 = $crl_url
# Policy OIDs
[ openssl_init ]
oid_section = additional_oids
[ additional_oids ]
blueMediumAssurance = Blue Medium Assurance, 1.3.6.1.4.1.0.1.7.8
blueMediumDevice = Blue Medium Device Assurance, 1.3.6.1.4.1.0.1.7.9
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
46 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
# Blue Network CA
[ default ]
ca = network-ca # CA name
dir = . # Top dir
base_url = http://pki.blue.se # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
name_opt = multiline,-esc_msb,utf8 # Display UTF-8 characters
openssl_conf = openssl_init # Library config section
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "SE"
organizationName = "Blue AB"
organizationalUnitName = "Blue Network CA"
commonName = "Blue Network CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = network_ca # The default CA section
[ network_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
serial = $dir/ca/$ca/db/$ca.crt.srl # Serial number file
crlnumber = $dir/ca/$ca/db/$ca.crl.srl # CRL number file
database = $dir/ca/$ca/db/$ca.db # Index file
unique_subject = no # Require unique subject
default_days = 3652 # How long to certify for
default_md = sha1 # MD to use
policy = match_pol # Default naming policy
email_in_dn = no # Add email to cert DN
preserve = no # Keep passed DN ordering
name_opt = $name_opt # Subject DN display options
cert_opt = ca_default # Certificate display options
copy_extensions = none # Copy extensions from CSR
x509_extensions = signing_ca_ext # Default cert extensions
[ match_pol ]
countryName = match
stateOrProvinceName = optional
localityName = optional
organizationName = match
organizationalUnitName = optional
commonName = supplied
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ intermediate_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumAssurance,blueMediumDevice
[ signing_ca_ext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumAssurance,blueMediumDevice
[ crl_ext ]
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
URI.0 = $crl_url
# Policy OIDs
[ openssl_init ]
oid_section = additional_oids
[ additional_oids ]
blueMediumAssurance = Blue Medium Assurance, 1.3.6.1.4.1.0.1.7.8
48 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
# Blue Identity CA
[ default ]
ca = identity-ca # CA name
dir = . # Top dir
base_url = http://pki.blue.se # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
name_opt = multiline,-esc_msb,utf8 # Display UTF-8 characters
openssl_conf = openssl_init # Library config section
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "SE"
organizationName = "Blue AB"
organizationalUnitName = "Blue Identity CA"
commonName = "Blue Identity CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = identity_ca # The default CA section
[ identity_ca ]
[ match_pol ]
countryName = match
stateOrProvinceName = optional
localityName = optional
organizationName = match
organizationalUnitName = optional
commonName = supplied
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ identity_ext ]
keyUsage = critical,digitalSignature
basicConstraints = CA:false
extendedKeyUsage = emailProtection,clientAuth,msSmartcardLogin
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumAssurance
[ encryption_ext ]
keyUsage = critical,keyEncipherment
basicConstraints = CA:false
extendedKeyUsage = emailProtection,msEFS
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumAssurance
50 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
[ crl_ext ]
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
URI.0 = $crl_url
# Policy OIDs
[ openssl_init ]
oid_section = additional_oids
[ additional_oids ]
blueMediumAssurance = Blue Medium Assurance, 1.3.6.1.4.1.0.1.7.8
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
# Blue Component CA
[ default ]
ca = component-ca # CA name
dir = . # Top dir
base_url = http://pki.blue.se # CA base URL
aia_url = $base_url/$ca.cer # CA certificate URL
crl_url = $base_url/$ca.crl # CRL distribution point
ocsp_url = http://ocsp.blue.se # OCSP responder URL
name_opt = multiline,-esc_msb,utf8 # Display UTF-8 characters
openssl_conf = openssl_init # Library config section
# CA certificate request
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = no # Don't prompt for DN
distinguished_name = ca_dn # DN section
req_extensions = ca_reqext # Desired extensions
[ ca_dn ]
countryName = "SE"
organizationName = "Blue AB"
organizationalUnitName = "Blue Component CA"
commonName = "Blue Component CA"
[ ca_reqext ]
keyUsage = critical,keyCertSign,cRLSign
basicConstraints = critical,CA:true,pathlen:0
subjectKeyIdentifier = hash
# CA operational settings
[ ca ]
default_ca = component_ca # The default CA section
[ component_ca ]
certificate = $dir/ca/$ca.crt # The CA cert
private_key = $dir/ca/$ca/private/$ca.key # CA private key
new_certs_dir = $dir/ca/$ca # Certificate archive
serial = $dir/ca/$ca/db/$ca.crt.srl # Serial number file
crlnumber = $dir/ca/$ca/db/$ca.crl.srl # CRL number file
database = $dir/ca/$ca/db/$ca.db # Index file
unique_subject = no # Require unique subject
default_days = 730 # How long to certify for
default_md = sha1 # MD to use
policy = match_pol # Default naming policy
email_in_dn = no # Add email to cert DN
preserve = no # Keep passed DN ordering
name_opt = $name_opt # Subject DN display options
cert_opt = ca_default # Certificate display options
copy_extensions = copy # Copy extensions from CSR
x509_extensions = server_ext # Default cert extensions
default_crl_days = 1 # How long before next CRL
crl_extensions = crl_ext # CRL extensions
[ match_pol ]
countryName = match
stateOrProvinceName = optional
localityName = optional
organizationName = match
organizationalUnitName = optional
commonName = supplied
[ any_pol ]
domainComponent = optional
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
# Extensions
[ server_ext ]
52 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
keyUsage = critical,digitalSignature,keyEncipherment
basicConstraints = CA:false
extendedKeyUsage = serverAuth,clientAuth
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @ocsp_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumDevice
[ client_ext ]
keyUsage = critical,digitalSignature
basicConstraints = CA:false
extendedKeyUsage = clientAuth
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @ocsp_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumDevice
[ timestamp_ext ]
keyUsage = critical,digitalSignature
basicConstraints = CA:false
extendedKeyUsage = critical,timeStamping
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
crlDistributionPoints = @crl_info
certificatePolicies = blueMediumDevice
[ ocspsign_ext ]
keyUsage = critical,digitalSignature
basicConstraints = CA:false
extendedKeyUsage = critical,OCSPSigning
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
noCheck = null
certificatePolicies = blueMediumDevice
[ crl_ext ]
authorityKeyIdentifier = keyid:always
authorityInfoAccess = @issuer_info
[ ocsp_info ]
caIssuers;URI.0 = $aia_url
OCSP;URI.0 = $ocsp_url
[ issuer_info ]
caIssuers;URI.0 = $aia_url
[ crl_info ]
URI.0 = $crl_url
# Policy OIDs
[ openssl_init ]
oid_section = additional_oids
[ additional_oids ]
blueMediumDevice = Blue Medium Device Assurance, 1.3.6.1.4.1.0.1.7.9
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/x509.html#NAME_OPTIONS
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/ca.html#CONFIGURATION_FILE_OPTIONS
• http://www.openssl.org/docs/apps/x509v3_config.html
And one configuration file per CSR type:
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = identity_dn # DN template
req_extensions = identity_reqext # Desired extensions
[ identity_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
emailAddress = "7. Email Address (eg, name@fqdn)"
emailAddress_max = 40
[ identity_reqext ]
keyUsage = critical,digitalSignature
extendedKeyUsage = emailProtection,clientAuth
subjectKeyIdentifier = hash
subjectAltName = email:move
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
54 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
• http://www.openssl.org/docs/apps/x509v3_config.html
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = yes # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = encryption_dn # DN template
req_extensions = encryption_reqext # Desired extensions
[ encryption_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
emailAddress = "7. Email Address (eg, name@fqdn)"
emailAddress_max = 40
[ encryption_reqext ]
keyUsage = critical,keyEncipherment
extendedKeyUsage = emailProtection
subjectKeyIdentifier = hash
subjectAltName = email:move
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
[ default ]
SAN = DNS:yourdomain.tld # Default value
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = no # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
[ server_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, FQDN) "
commonName_max = 64
[ server_reqext ]
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = serverAuth,clientAuth
subjectKeyIdentifier = hash
subjectAltName = $ENV::SAN
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = no # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = client_dn # DN template
req_extensions = client_reqext # Desired extensions
[ client_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
[ client_reqext ]
keyUsage = critical,digitalSignature
56 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
extendedKeyUsage = clientAuth
subjectKeyIdentifier = hash
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = no # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = timestamp_dn # DN template
req_extensions = timestamp_reqext # Desired extensions
[ timestamp_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
[ timestamp_reqext ]
keyUsage = critical,digitalSignature
extendedKeyUsage = critical,timeStamping
subjectKeyIdentifier = hash
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
[ req ]
default_bits = 2048 # RSA key size
encrypt_key = no # Protect private key
default_md = sha1 # MD to use
utf8 = yes # Input is UTF-8
string_mask = utf8only # Emit UTF-8 strings
prompt = yes # Prompt for DN
distinguished_name = ocspsign_dn # DN template
req_extensions = ocspsign_reqext # Desired extensions
[ ocspsign_dn ]
countryName = "1. Country Name (2 letters) (eg, US) "
countryName_max = 2
stateOrProvinceName = "2. State or Province Name (eg, region) "
localityName = "3. Locality Name (eg, city) "
organizationName = "4. Organization Name (eg, company) "
organizationalUnitName = "5. Organizational Unit Name (eg, section) "
commonName = "6. Common Name (eg, full name)"
commonName_max = 64
[ ocspsign_reqext ]
keyUsage = critical,digitalSignature
extendedKeyUsage = critical,OCSPSigning
subjectKeyIdentifier = hash
References
• http://www.openssl.org/docs/apps/config.html
• http://www.openssl.org/docs/apps/req.html#CONFIGURATION_FILE_FORMAT
• http://www.openssl.org/docs/apps/x509v3_config.html
Please study the configuration files before you continue.
1. Create Root CA
cp /dev/null ca/root-ca/db/root-ca.db
cp /dev/null ca/root-ca/db/root-ca.db.attr
echo 01 > ca/root-ca/db/root-ca.crt.srl
echo 01 > ca/root-ca/db/root-ca.crl.srl
58 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl ca -selfsign \
-config etc/root-ca.conf \
-in ca/root-ca.csr \
-out ca/root-ca.crt \
-extensions root_ca_ext \
-enddate 20301231235959Z
2048-bit RSA keys are deemed safe until 2030 (RSA Labs).
openssl ca -gencrl \
-config etc/root-ca.conf \
-out crl/root-ca.crl
2. Create Network CA
cp /dev/null ca/network-ca/db/network-ca.db
cp /dev/null ca/network-ca/db/network-ca.db.attr
echo 01 > ca/network-ca/db/network-ca.crt.srl
echo 01 > ca/network-ca/db/network-ca.crl.srl
openssl ca \
-config etc/root-ca.conf \
-in ca/network-ca.csr \
-out ca/network-ca.crt \
-extensions intermediate_ca_ext \
-enddate 20301231235959Z
Intermediate CAs should have the same life span as their root CAs.
openssl ca -gencrl \
-config etc/network-ca.conf \
-out crl/network-ca.crl
3. Create Identity CA
cp /dev/null ca/identity-ca/db/identity-ca.db
cp /dev/null ca/identity-ca/db/identity-ca.db.attr
echo 01 > ca/identity-ca/db/identity-ca.crt.srl
echo 01 > ca/identity-ca/db/identity-ca.crl.srl
60 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl ca \
-config etc/network-ca.conf \
-in ca/identity-ca.csr \
-out ca/identity-ca.crt \
-extensions signing_ca_ext
openssl ca -gencrl \
-config etc/identity-ca.conf \
-out crl/identity-ca.crl
4. Create Component CA
cp /dev/null ca/component-ca/db/component-ca.db
cp /dev/null ca/component-ca/db/component-ca.db.attr
echo 01 > ca/component-ca/db/component-ca.crt.srl
echo 01 > ca/component-ca/db/component-ca.crl.srl
openssl ca \
-config etc/network-ca.conf \
-in ca/component-ca.csr \
-out ca/component-ca.crt \
-extensions signing_ca_ext
openssl ca -gencrl \
-config etc/component-ca.conf \
-out crl/component-ca.crl
5. Operate Identity CA
openssl ca \
-config etc/identity-ca.conf \
-in certs/fred-id.csr \
-out certs/fred-id.crt \
-extensions identity_ext
62 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl ca \
-config etc/identity-ca.conf \
-in certs/fred-enc.csr \
-out certs/fred-enc.crt \
-extensions encryption_ext
openssl ca \
-config etc/identity-ca.conf \
-revoke ca/identity-ca/02.pem \
-crl_reason superseded
openssl ca -gencrl \
-config etc/identity-ca.conf \
-out crl/identity-ca.crl
6. Operate Component CA
SAN=DNS:blue.se,DNS:www.blue.se \
openssl req -new \
-config etc/server.conf \
-out certs/blue.se.csr \
-keyout certs/blue.se.key
openssl ca \
-config etc/component-ca.conf \
-in certs/blue.se.csr \
-out certs/blue.se.crt \
-extensions server_ext
openssl ca \
-config etc/component-ca.conf \
-in certs/net-mon.csr \
-out certs/net-mon.crt \
-extensions client_ext
64 Chapter 3. Examples
OpenSSL PKI Tutorial, Release v1.1
openssl ca \
-config etc/component-ca.conf \
-in certs/tsa.csr \
-out certs/tsa.crt \
-extensions timestamp_ext \
-days 1826
openssl ca \
-config etc/component-ca.conf \
-in certs/ocsp.csr \
-out certs/ocsp.crt \
-extensions ocspsign_ext \
-days 14
openssl ca \
-config etc/component-ca.conf \
-revoke ca/component-ca/02.pem \
-crl_reason superseded
openssl ca -gencrl \
-config etc/component-ca.conf \
-out crl/component-ca.crl
7. Publish Certificates
openssl x509 \
-in ca/root-ca.crt \
-out ca/root-ca.cer \
-outform der
All published certificates must be in DER format. MIME type: application/pkix-cert. [RFC 2585#section-4.1]
openssl crl \
-in crl/network-ca.crl \
-out crl/network-ca.crl \
-outform der
All published CRLs must be in DER format. MIME type: application/pkix-crl. [RFC 2585#section-4.2]
PKCS#7 is used to bundle two or more certificates. MIME type: application/pkcs7-mime. [RFC 5273#page-3]
References
• http://www.openssl.org/docs/apps/req.html
• http://www.openssl.org/docs/apps/ca.html
• http://www.openssl.org/docs/apps/x509.html
• http://www.openssl.org/docs/apps/crl.html
• http://www.openssl.org/docs/apps/crl2pkcs7.html
• http://www.openssl.org/docs/apps/pkcs7.html
• http://www.openssl.org/docs/apps/pkcs12.html
66 Chapter 3. Examples
CHAPTER 4
Appendices
MIME Types
This section takes a closer look at the MIME types and file extensions used.
File Types
MIME Types
The list of MIME types and file extensions however is easily twice as long:
67
OpenSSL PKI Tutorial, Release v1.1
application/x-x509-user-cert .crt
application/x-pkcs7-crl .crl
application/x-pem-file .pem
application/x-pkcs12 .p12 .pfx
CA Database
Appendix B: CA Database
Index File
The index file consists of zero or more lines, each containing the following fields separated by tab characters:
1. Certificate status flag (V=valid, R=revoked, E=expired).
1 The presence of a MIME type does not imply the respective files should be published on the Internet. In particular, you will never want to
stunnel, etc.
3 This is a plain CRL and not PKCS#7 wrapped. The MIME type says ‘pkcs7’ for historical reasons only.
68 Chapter 4. Appendices
OpenSSL PKI Tutorial, Release v1.1
Attribute File
The attribute file contains a single line: unique_subject = no. It reflects the setting in the CA section of the
configuration file at the time the first record is added to the database.
Limitations
4.2. CA Database 69
OpenSSL PKI Tutorial, Release v1.1
70 Chapter 4. Appendices
CHAPTER 5
References
RFC 5280 Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile
RFC 2585 Internet X.509 Public Key Infrastructure Operational Protocols: FTP and HTTP
RFC 5750 Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 Certificate Handling
RFC 6125 Representation and Verification of Domain-Based Application Service Identity within Internet Public Key
Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS)
Baseline Requirements [pdf, opens in browser] CA/Browser Forum Baseline Requirements for the Issuance and
Management of Publicly-Trusted Certificates
X.509 Recommendation [pdf, direct download] ITU-T X.509 Public-Key and Attribute Certificate Frameworks
Recommendation
OpenSSL TEST CA [pdf, direct download] Carillon Information Security: How to Set Up an OpenSSL TEST CA
for Interoperability Testing with CertiPath
71
OpenSSL PKI Tutorial, Release v1.1
72 Chapter 5. References
Index
R
RFC
RFC 2315#section-9.1, 68
RFC 2585, 71
RFC 2585#section-3, 19, 20
RFC 2585#section-4.1, 42, 65, 68
RFC 2585#section-4.2, 43, 66, 68
RFC 4880, 5
RFC 5273#page-3, 43, 66, 68
RFC 5280, 71
RFC 5280#section-4, 68
RFC 5280#section-5, 68
RFC 5750, 71
RFC 5958#section-7.1, 68
RFC 5967#section-3.1, 68
RFC 6125, 71
73