Create A Certificate Signing Request

From Postmaster Administration Wiki
Jump to: navigation, search

TLS and SSL require the use of either commercial or self-signed server certificates by which a server will identify themselves and establish encrypted communications. Commercial certificates are highly recommended for online stores using HTTPS or for applications and services that deal with the public, such as ISP mail services SMTP, POP, IMAP, and web mail using HTTPS. Self-signed certificates are sufficient for development, testing, and/or private in-house applications and services. In either case, an administrator will require a CSR for each host machine to be signed by a certificate authority (CA).

There are three steps involved: generate a private key if needed, generate a CSR specifying the host name for the common name (CN) field and other salient details, then submitting the CSR for signing.

The Common Name (CN) is the most important field in a certificate. It must contain the DNS host name of the server. So if your inbound mail server is, then your certificate's CN must also be Otherwise, the public will see warnings about invalid and/or mismatched certificates to host names.

Generate a private key.

$ openssl genrsa -out 2048
$ chmod u=r,go=

The generated private key file,, uses 2048 bit encryption. It is possible to specify other values for stronger or weaker encryption, based on powers of 2 (1024, 2048, 4096). Higher values are better at  the cost of slower encryption / decryption. Generally its is a good practise to have a private key for each host machine, since the private key will be required by all the applications on the host supporting TLS. In the event a machine is compromised, only the private key for that machine can be compromised.

Generate CSR for host machine.

$ openssl req -new -key -out
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) []: CA
State or Province Name (full name) []: Quebec
Locality Name (eg, city) []: Montreal
Organization Name (eg, company) []: Example Ltd.
Organizational Unit Name (eg, section) []: IT Dept.
Common Name (eg, fully qualified host name) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: 
An optional company name []: 

A file called will be generated incorporating the data entered.

For server certificates, which are used by applications and services operating on a host machine, it is best not to supply a certificate password; otherwise when a host machine reboots, TLS based services that automatically start will pause and prompt for a password.

The actual content of the CSR file is Base64 encoded, but can be viewed with:

View CSR content.

$ openssl req -text -noout -in
Certificate Request:
        Version: 0 (0x0)
        Subject: C=CA, ST=Quebec, L=Montreal, O=Example Ltd., OU=IT Dept.,
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            RSA Public Key: (1024 bit)
                Modulus (1024 bit):
                Exponent: 65537 (0x10001)
    Signature Algorithm: md5WithRSAEncryption

The can then be submitted to Gandi, GoDaddy, Verisign, or similar certificate authority. The alternative is to self-sign a certificate for private uses.