Creating certificate on Linux for a website

Anju
1 min readApr 19, 2021

--

The initial files which we create in our env. is csr and the associated key then we can share the csr with a trusted certificate authority to create cer using it.

Create a req.conf file

[req]
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = req_ext
[req_distinguished_name]
countryName = Country Name (2 letter code)
stateOrProvinceName = State or Province Name (fulle name )
localityName = Locality Name (eg, city)
organizationName = Organization Name (eg, compagny)
organizationalUnitName = Department ( eg, IT )
commonName = Common Name (eg server FQDN or YOUR name)
[req_ext]
subjectAltName = @alt_names
[alt_names]
DNS.1 = yoursite.example.com

Generate the csr and key (It is recommended to always create a new key for a csr)

openssl req -new -out <your-site-name>.csr -newkey rsa:2048 -nodes -sha256 -keyout <your-site-name>.key -config req.conf

To read your csr file

# If you cat the csr for it will show block of encoded text, so to read file we can use opensslopenssl req -text -noout -verify -in <your-site-name>.csr

To read key file

openssl x509 -noout -text -in  <your-site-name>.key

--

--

Anju
Anju

Written by Anju

A DevOps engineer who loves automating everything (almost), exploring new places, and finding peace in nature. Always looking for the next adventure!

No responses yet