Below Commands 1-5 helps in creating the Certificate Chain
Command to Create RootCA's Private Key and Self Signed Certificate
openssl req -new -nodes -newkey rsa:2048 -sha256 -days 100 -keyout rootPrivateKey.key -x509 -out rootCACertificate.pem
Note: Command to convert RootCA Certificte from .crt to .pem format
openssl x509 -outform pem -in rootCACertificate.pem -out rootCACertificate.crt
Command to Create Intermediate CA's Private Key and it's Certificate Sign Request
openssl req -new -nodes -newkey rsa:2048 -keyout intermediateCAPrivateKey.key -out intermediateCACertificateSignRequest.csr
Command to Create Intermediate CA's Certificate Signed by RootCA
openssl x509 -req -sha256 -days 100 -in intermediateCACertificateSignRequest.csr -CA rootCACertificate.pem -CAkey rootPrivateKey.key -CAcreateserial -extfile domain.ext -out intermediateCACertificate.crt
Contents of domain.ext is provided below:
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
Command to Create Server's Private Key and Sign Request
openssl req -new -nodes -newkey rsa:2048 -keyout serverPrivateKey.key -out serverSignRequest.csr
Command to Create Server's Certificate Signed by IntermediateCA
openssl x509 -req -sha256 -days 100 -in serverSignRequest.csr -CA intermediateCACertificate.crt -CAkey intermediateCAPrivateKey.key -CAcreateserial -extfile domain.ext -out serverCertificate.crt
Contents of domain.ext is provided below:
basicConstraints = CA:FALSE keyUsage = nonRepudiation,
digitalSignature, keyEncipherment
subjectAltName = @alt_names
[ alt_names ] DNS.1 = localhost
Note: Command to convert Server's Private Key in .key Format to .PEM format.
openssl rsa -in serverPrivateKey.key -out serverPrivateKey.pem
Here the Root CA is Self Signed. Thus Browsers doesn't recognize it. To ensure Browser recognise, open IE ->Tools->Internet Options -> Content -> Import the Root CA in Trusted Certification Authority Section and the Intermediate CA in Intermediate Certification Authority Section.
The Server Certificate and Server's Private Key is kept in Server you run serve the web pages.
Once you request for webpages, you can find the Server Certificate gets validated against the Certificate Chain