By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
Aadil Nabi
  • Technology
    Technology
    Modern technology has become a total phenomenon for civilization, the defining force of a new social order in which efficiency is no longer an option…
    Show More
    Top News
    How to use OpenSSL to create Root CA, Intermediate CA, and Certificates?
    December 22, 2023
    SHA-1 Disabled by Oracle, Fix Signing Issues…
    July 16, 2023
    Latest cybersecurity trends to be taken care of !!
    December 22, 2023
    Latest News
    Latest cybersecurity trends to be taken care of !!
    December 22, 2023
    SHA-1 Disabled by Oracle, Fix Signing Issues…
    July 16, 2023
    How to use OpenSSL to create Root CA, Intermediate CA, and Certificates?
    December 22, 2023
  • Gadget
    GadgetShow More
  • Cybersecurity
  • Tech News
Search
  • Contact
  • Blog
  • Complaint
  • Advertise
© 2023 aadilnabi.com. All Rights Reserved.
Reading: How to use OpenSSL to create Root CA, Intermediate CA, and Certificates?
Share
Sign In
Notification Show More
Latest News
stay_motivated
Motivation, Tool to unleash the best in You
Entrepreneurship
Latest cybersecurity trends to be taken care of !!
Cybersecurity
kashmir almonds
Healthy Snacking in India!!!
Entrepreneurship Uncategorized
SHA-1 Disabled by Oracle, Fix Signing Issues…
Cybersecurity
Right Product to Migrate To? KeySecure & DSM to CM Migration…
Tech News
Aa
Aadil Nabi
Aa
  • Technology
  • Gadget
  • Cybersecurity
  • Tech News
Search
  • Technology
  • Gadget
  • Cybersecurity
  • Tech News
Have an existing account? Sign In
Follow US
  • Contact
  • Blog
  • Complaint
  • Advertise
© 2022 Foxiz News Network. Ruby Design Company. All Rights Reserved.
Aadil Nabi > Blog > Technology > Cybersecurity > How to use OpenSSL to create Root CA, Intermediate CA, and Certificates?
Cybersecurity

How to use OpenSSL to create Root CA, Intermediate CA, and Certificates?

Aadil Nabi
Last updated: 2023/12/22 at 10:48 AM
Aadil Nabi
Share
7 Min Read
SHARE

In this blog we will be creating a root CA using the openssl command-line and later, we will be using this root CA to sign an intermediate or Issuing CA, which finally will be issueing server and client certificates

Contents
Steps to create a Root CA1: Create the directory and directory structure2: Create a Root CA configuration file named as openssl.cnf3: Create the root key4: Create the selfsigned root certificate5: Verify the root certificate

This blog is created taking the intermediate developers into consideration who does have the basic knowledge of OpenSSL library and command line.

Steps to create a Root CA

1: Create the directory and directory structure

  • mkdir /root/ca
  • cd /root/ca
  • mkdir certs crl newcerts private
  • chmod 700 private
  • touch index.txt
  • echo 1000 > serial
The index.txt and serial files act as a flat file database to keep track of signed certificates.

2: Create a Root CA configuration file named as openssl.cnf

You must create a configuration file for OpenSSL to use. You can Copy the root CA configuration file content from the openssl.cnf mentioned below to /root/ca/openssl.cnf
# OpenSSL root CA configuration file.
# Copy to `/root/ca/openssl.cnf`.

[ ca ]
# `man ca`
default_ca = CA_default

[ CA_default ]
# Directory and file locations.
dir               = /root/ca
certs             = $dir/certs
crl_dir           = $dir/crl
new_certs_dir     = $dir/newcerts
database          = $dir/index.txt
serial            = $dir/serial
RANDFILE          = $dir/private/.rand

# The root key and root certificate.
private_key       = $dir/private/ca.key.pem
certificate       = $dir/certs/ca.cert.pem

# For certificate revocation lists.
crlnumber         = $dir/crlnumber
crl               = $dir/crl/ca.crl.pem
crl_extensions    = crl_ext
default_crl_days  = 30

# SHA-1 is deprecated, so use SHA-2 instead.
default_md        = sha256

name_opt          = ca_default
cert_opt          = ca_default
default_days      = 375
preserve          = no
policy            = policy_strict

[ policy_strict ]
# The root CA should only sign intermediate certificates that match.
# See the POLICY FORMAT section of `man ca`.
countryName             = match
stateOrProvinceName     = match
organizationName        = match
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

[ policy_loose ]
# Allow the intermediate CA to sign a more diverse range of certificates.
# See the POLICY FORMAT section of the `ca` man page.
countryName             = optional
stateOrProvinceName     = optional
localityName            = optional
organizationName        = optional
organizationalUnitName  = optional
commonName              = supplied
emailAddress            = optional

[ req ]
# Options for the `req` tool (`man req`).
default_bits        = 2048
distinguished_name  = req_distinguished_name
string_mask         = utf8only

# SHA-1 is deprecated, so use SHA-2 instead.
default_md          = sha256

# Extension to add when the -x509 option is used.
x509_extensions     = v3_ca

[ req_distinguished_name ]
# See <https://en.wikipedia.org/wiki/Certificate_signing_request>.
countryName                     = Country Name (2 letter code)
stateOrProvinceName             = State or Province Name
localityName                    = Locality Name
0.organizationName              = Organization Name
organizationalUnitName          = Organizational Unit Name
commonName                      = Common Name
emailAddress                    = Email Address

# Optionally, specify some defaults.
countryName_default             = IN
stateOrProvinceName_default     = Noida
localityName_default            =
0.organizationName_default      = Abc
organizationalUnitName_default  =
emailAddress_default            =

[ v3_ca ]
# Extensions for a typical CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

[ v3_intermediate_ca ]
# Extensions for a typical intermediate CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true, pathlen:0
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

[ usr_cert ]
# Extensions for client certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = client, email
nsComment = "OpenSSL Generated Client Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth, emailProtection

[ server_cert ]
# Extensions for server certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = server
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth

[ crl_ext ]
# Extension for CRLs (`man x509v3_config`).
authorityKeyIdentifier=keyid:always

[ ocsp ]
# Extension for OCSP signing certificates (`man ocsp`).
basicConstraints = CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, digitalSignature
extendedKeyUsage = critical, OCSPSigning

3: Create the root key

Create the root key (ca.key.pem) and keep it absolutely secure. Anyone in possession of the root key can issue trusted certificates. Encrypt the root key with AES 256-bit encryption and a strong password.
Use 4096 bits for all root and intermediate certificate authority keys. You’ll still be able to sign server and client certificates of a shorter length.
  • cd /root/ca
  • openssl genrsa -aes256 -out private/ca.key.pem 4096
  • chmod 400 private/ca.key.pem

4: Create the selfsigned root certificate

Use the root key (ca.key.pem) to create a root certificate (ca.cert.pem). Give the root certificate a long expiry date, such as twenty years. Once the root certificate expires, all certificates signed by the CA become invalid.
Whenever you use the req tool, you must specify a configuration file to use with the -config option, otherwise OpenSSL will default to /etc/pki/tls/openssl.cnf.
  • cd /root/ca
  • openssl req -config openssl.cnf -key private/ca.key.pem -new -x509 -days 7300 -sha256 -extensions v3_ca -out certs/ca.cert.pem
  • chmod 444 certs/ca.cert.pem

5: Verify the root certificate

  • openssl x509 -noout -text -in certs/ca.cert.pem
The output will be like :

the Signature Algorithm used
the dates of certificate Validity
the Public-Key bit length
the Issuer, which is the entity that signed the certificate
the Subject, which refers to the certificate itself
The Issuer and Subject are identical as the certificate is self-signed. Note that all root certificates are self-signed.

Signature Algorithm: sha256WithRSAEncryption
    Issuer: C=IN, ST=Noida,
            O=Abc, OU=Abc Certificate Authority,
            CN=Abc Root CA
    Validity
        Not Before: Apr 11 12:22:58 2015 GMT
        Not After : Apr  6 12:22:58 2035 GMT
    Subject: C=IN, ST=Noida,
             O=Abc, OU=Abc Certificate Authority,
             CN=Aadil Root CA
    Subject Public Key Info:
        Public Key Algorithm: rsaEncryption
            Public-Key: (4096 bit)
			
The output also shows the X509v3 extensions. We applied the v3_ca extension, so the options from [ v3_ca ] should be reflected in the output.

X509v3 extensions:
    X509v3 Subject Key Identifier:
        38:58:29:2F:6B:57:79:4F:39:FD:32:35:60:74:92:60:6E:E8:2A:31
    X509v3 Authority Key Identifier:
        keyid:38:58:29:2F:6B:57:79:4F:39:FD:32:35:60:74:92:60:6E:E8:2A:31

    X509v3 Basic Constraints: critical
        CA:TRUE
    X509v3 Key Usage: critical
        Digital Signature, Certificate Sign, CRL Sign
Read more: How to use OpenSSL to create Root CA, Intermediate CA, and Certificates?

You Might Also Like

Latest cybersecurity trends to be taken care of !!

SHA-1 Disabled by Oracle, Fix Signing Issues…

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Aadil Nabi July 14, 2022
Share this Article
Facebook Twitter Whatsapp Whatsapp LinkedIn Copy Link Print
Share
What do you think?
Love1
Sad0
Happy0
Sleepy0
Angry0
Dead0
Surprise0
Wink0
Next Article Right Product to Migrate To? KeySecure & DSM to CM Migration…
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow
banner banner
Create an Amazing Newspaper
Discover thousands of options, easy to customize layouts, one-click to import demo and much more.
Learn More

Latest News

stay_motivated
Motivation, Tool to unleash the best in You
Entrepreneurship
Latest cybersecurity trends to be taken care of !!
Cybersecurity
kashmir almonds
Healthy Snacking in India!!!
Entrepreneurship Uncategorized
SHA-1 Disabled by Oracle, Fix Signing Issues…
Cybersecurity

You Might also Like

Cybersecurity

Latest cybersecurity trends to be taken care of !!

3 Min Read
Cybersecurity

SHA-1 Disabled by Oracle, Fix Signing Issues…

7 Min Read
Follow US

© 2023 aadilnabi.com. All Rights Reserved.

  • PRIVACY NOTICE
  • YOUR PRIVACY RIGHTS
  • INTEREST-BASE ADSNew
  • TERMS OF USE

Removed from reading list

Undo
Go to mobile version
Welcome Back!

Sign in to your account

Register Lost your password?