1

I've been trying to put together a certificate chain. I have the private key (privatekey.pem) and CSR (csr.pem) that I submitted to the Certificate Authority/CA.

I took the CA's certificate and put the contents in a file (ca.crt). The ca.crt starts with a -----BEGIN CERTIFICATE----- line and then the hashed stuff. I still need the certificate chain though, and looking at the certificate chain example here http://docs.aws.amazon.com/IAM/latest/UserGuide/InstallCert.html#SampleCert

I assume that what I have in the privatekey.pem is the root certificate (right?) and ca.crt is the intermediate certificate 1 in the sample chain in that link. If that's the case how/where do I get the other intermediate certificate? If I'm misunderstanding this, what or how do I get/generate the order?

1
  • What is the URL to your server? Also, do not send the root certificate as mentioned in Amazon docs. The client must trust the root - it is not sent. More than likely, browsers will already trust it. The one exception I have seen to the "don't send the root/ca rule" is a cross-certified root using a bridge, which I doubt you have. You would see something like that in US Federal, where, for example, one agency would cross-certify another agency's PKI so certs from both PKIs could be used.
    – jww
    Jul 5, 2014 at 4:53

3 Answers 3

1

You seem to be mixing up several aspects here. What you need to get the final result is

  1. your private key
  2. the root certificate, which is equal for everybody using the same CA (that is what your ca.crt seems to be)
  3. a/some intermediate certificates, usually found on the CA's site
  4. the result of the submitted CSR, which then is your certificate.

2-4 make up the certificate chain.

1
  • Seems to make sense. But I'm still confused about how to actually make the chain file. Do I just paste them in?
    – Adron
    Jul 7, 2014 at 19:37
1

Adron,

the privatekey.pem is the private key for the cert that you requested from the CA.

the root ca cert will be the certificate from the top of the particular PKI that issued your cert and will be a self signed cert.

the intermediate ca certs are from sub-ca's below the root CA.

e.g. example.com has a root CA call exampleRootCA and a sub CA called exampleSubCA.

exampleSubCA issues you an SSL cert AdronSSL

your certificate chain will be AdronSSL -> exampleSubCA -> exampleRootCA

hope this helps

1
  • OK. I guess what I'm still confused about is how do I make the chain? Do I just paste them into a text file that is ordered as stated and save it as a chain.crt/chain.pem or something?
    – Adron
    Jul 7, 2014 at 19:37
-2

Below Commands 1-5 helps in creating the Certificate Chain

  1. 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
  1. 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

  2. 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
  1. Command to Create Server's Private Key and Sign Request

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

  2. 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .