Check this Out!Visit our social network pages for recent updates!

Lesson 38: Generate Certificate Signing Request (CSR) for Apache2

Students lesson 38 assignment: How do you create a certificate signing request for Apache2 on Linux systems?

Certificate signing request is the first step you take in acquiring trusted SSL/TLS certificates for your domain. If you need to protect the information being transferred between your web server and client’s browsers, you must install SSL/TLS certificates.

Before you can generate SSL certificates, you must first generate or create a CSR request and provide that to the certificate provider. The provider will then use the request to generate a certificate for your server.

The CSR request contains information that will be used to create the certificate. These include, the organization name, common name (domain), locality, country and more.

It also contains the public key that is used to generate a certificate. A private key is also created during the time of the CSR creation.

This brief tutorial is going to show you how to easily generate a Certificate Signing Request for your Apache2 servers on Linux systems.

Step 1: Creating CSR for Apache2 web server

When you’re ready to protect your website with SSL/TLS certificate, you must first generate a certificate signing request. This request contains information that is needed to generate a trusted certificate.

To generate a certificate for Apache2 webserver on Linux systems, logon to your computer as root and run the below command.

openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

When you press the Enter key, you’ll then be asked series of question related to the certificate you’re requesting. Find the highlighted field below to give you an idea.

Generating a 2048 bit RSA private key
........+++
.....................+++
writing new private key to 'mydomain.key'
-----
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) [AU]:US
State or Province Name (full name) [Some-State]:Minnesota
Locality Name (eg, city) []:Minneapolis
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Blog Company
Organizational Unit Name (eg, section) []:SSL
Common Name (e.g. server FQDN or YOUR name) []:yourdomain.com
Email Address []:admin@mydomain.com

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

It important that you leave the password field blank above, or you’ll be prompted always after restart Apache2 server.

This command creates the request as well as the server’s private key. The private key must be protected and kept very safe. This is very important.

Step 2: Send the CSR content to your certificate provider

After you creating the request above, look into the same directory you ran the command and you’ll find a file named after your domain, called yourdomain.csr.

Open the youdomain.csr to view the content. Then copy and paste it to your certificate provider.

cat yourdomain.csr

-----BEGIN CERTIFICATE REQUEST-----
MIIC3zCCAccCAQAwgZkxCzAJBgNVBAYTAlVTMRIwEAYDVQQIDAlNaW5uZXNvdGEx
FDASBgNVBAcMC01pbm5lYXBvbGlzMRgwFgYDVQQKDA9NeSBCbG9nIENvbXBhbnkx
DDAKBgNVBAsMA1NTTDEVMBMGA1UEAwwMbXlkb21haW4uY29tMSEwHwYJKoZIhvcN
AQkBFhJhZG1pbkBteWRvbWFpbi5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQDbxsZzIAdeGuIN3m00F71WBHklL8f5I3j4UebS7ISqL1HWb7KVEj+r
QKBQzmZ70Izq152+6BTF/AeMwzusUrcr3iOaOThFYqBAx2UYCHBmu3xcGviflwz/
7GnvgUA2b0UL8pNiVCrxk7Dmu1tG0GCo5F5bE1k+60NnUJdtYTTjh1CXguFhKdnn
nGPiAEq9drXnrOEUWjgV3Flkb0XEUXxKt20flPAmp2viobs46TtY3CMgZrl5DaOs
bcCFzTNywCXyC5wj1baWAVxUIMETpAvXjFSINMhu/zN+qDVZe44c2SZEkbXchBvR
xtmeLLO9Y8E9e0KRx373hdHdDKWjXNv7AgMBAAGgADANBgkqhkiG9w0BAQsFAAOC
AQEA047VTE5ayHQG5efbpE4jxGCUBHeAHTZw4sXy2s8q/beCXnEFdbbk2R7+B9rZ
1Q5FR5sZq9tiJ/7kcZEfE/C4ZRiQi1dSkhvZWPOvfVJn7ETdyFUp+e3Yh5dGQBRE
qOGwI5vxfoWlKkgYmAKYKVd2W+QibofAiXNkRzsW3ecZUG9Dj7rD+Y+VeVKX0sCL
doOCxZlEjRoKjJC/f+kcuGaHvJMNXGBApniGTKCsNnIypVdDUcKedvl7wF8mxdqo
j70uQaeY7tqjaLIAeqdd9WHADCxwCmSJovPqWA9JQN+TbpLG4oqSu7n8EdFcgSVJ
P8rSweAqn1RQb88NuLdQuxdzBQ==
-----END CERTIFICATE REQUEST-----

Copy the entire content from the BEGIN to the END.

That’s it! In our next post we’ll show you how to install the certificate after receiving.

Thanks for reading and please come back soon.

You may also like this post:

Lesson 36: Installing the LEMP Stack on Ubuntu

 

Leave a Reply