I am studying the X509 certificate structure and here is an OpenSSL configuration file for generating the certificate. ("sth" just mean the actual string is removed)

[ req ]
prompt                 = no
distinguished_name     = req_distinguished_name
x509_extensions        = v3_ca

[ req_distinguished_name ]
countryName            = sth
localityName           = sth
organizationalUnitName = sth
commonName             = sth
emailAddress           = sth

[ v3_ca ]
basicConstraints       = critical, CA:TRUE, pathlen:1
keyUsage               = critical, keyCertSign

Here are my questions:

  • What does req_distinguished_name mean and how is this being used?

  • What do critical and pathlen mean in basicContraints?
    basicConstraints = critical, CA:TRUE, pathlen:1

  • What does critical mean in keyUsage?

  • $\begingroup$ If you care only about the certificate (or CSR), I concur with the answers. If you care exactly how the options in the OpenSSL config file map to a cert/CSR, see the manpage for req for DISTINGUISHED NAME and the manpage for x509v3_config for all extensions including basicconstraints and keyusage. The manpages should be present on your system if Unixy, and are also online at openssl.org/docs/manpages.html . $\endgroup$ – dave_thompson_085 May 28 '16 at 2:34

All the answers can be found in RFC 5280 which defines the X.509 certificate format.

1. What does req_distinguished_name mean and how is this being used?

It looks like OpenSSL is spitting this out in .ini format, so I would guess that

distinguished_name     = req_distinguished_name

means that the required distinguished name info can be found in tho[req_distinguished_name] section below. Similarly,

x509_extensions        = v3_ca

means that the extension stuff can be found in the [v3_ca] section.

In X.509, a Distinguished Name (DN) is a unique identifier for the person or server who holds this certificate. DNs are structured much the same as a domain name in a URL starting with a country code, and going right down to the name of the person or server.

2. What do critical and pathlen mean in basicContraints? basicConstraints = critical, CA:TRUE, pathlen:1

RFC 5280 Section Basic Constraints says:

The basic constraints extension identifies whether the subject of the certificate is a CA and the maximum depth of valid certification paths that include this certificate.

So CA:TRUE, pathlen:1 means that this is a self-signed root CA and it can only issue end-user certs not subordinate CAs, since any certs they issue would have a pathlen > 1.

3. What does critical mean in X.509 certificates?

RFC 5280 Section 4.2. Certificate Extensions says:

Each extension in a certificate is designated as either critical or non-critical. A certificate-using system MUST reject the certificate if it encounters a critical extension it does not recognize or a critical extension that contains information that it cannot process. A non-critical extension MAY be ignored if it is not recognized, but MUST be processed if it is recognized.

So basically, critical means that errors in this data should be considered fatal, non-critical means that errors can be ignored.

| improve this answer | |
  • $\begingroup$ The description for pathlen is totally wrong. See the answer from @sejpm $\endgroup$ – Taha Jahangir Jun 16 at 17:29

What does req_distinguished_name mean and how is this being used?

This is the Distinguished Name (DN) which will be used in your certificate request. This is usually a string describing the owner of the public key and usually you see things like common Name (CN) and e-mail addresses here. Additionally you can put regional and organisational identifying information here (e.g. organisation name (O), organisation unit (OU), country, state and city).

What do critical and pathlen mean in basicContraints?

Critical means: "100% make sure you enforce this rules!", in the sense that if the implementation doesn't understand what this extension means, it should fail validation. The pathlen controls how deep the certificate issuance path is that is going out from this CA, if you set pathlen=0 you can only issue end-entity certificates (or invalid CAs), which is considered a feature if you for example have intermediate CAs who only every should issue such certificates or if you have sell an intermediate CA but don't want the customer to issue CA certificates themselves. Essentially pathlen counts the the maximal number of CAs between the current CA certificate and the end-entity certificate. That is, with pathlen of 1, there still can be one more intermediate CA between the current CA and the end entity, however that CA could only issue end-entity certificates. (thanks go to Megascolia for making me aware of a mistake in a previous version of this answer).

What does critical mean in keyUsage?

Same as above. "100% make sure you enforce this rules!",i.e. the implementation MUST enforce the key usage and if it doesn't understand / know the extension validation must fail, e.g. that the key is only used to do the stuff which is allowed by the associated certificate, any other key usages should also be rejected by other implementations interacting with this key's signed / encrypted data. In your case this means that the issued certificate would be invalid to sign or encrypt data and thus any compliant application would reject to encrypt data for you / output data signed under that certificate as "invalid".

| improve this answer | |

The existing answers by Mike Ounsworth and SEJPM are good, but both are wrong about the meaning of "pathlen=1". With a PathLenConstraint of 1 you are still able to issue certificates to CAs, with a PathLenConstraint you can only issue end-entity certificates. This other answer from Stackoverflow explains the issue very well.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.