distinguished name order

Mike <debian-jy+RX4/[email protected]> Tue, 29 Jul 2025 22:19:05 +0000
Newsgroups gmane.comp.encryption.openssl.user
Message-ID <[email protected]>
ITU X.501 (10/19) <https://www.itu.int/rec/T-REC-X.501-201910-I/en>,
section 9.2 says that the `RDNSequence` that makes up a `DistinguishedName`
"start[s] with the root" RDN.

RFC 4514, section 2.1 <https://datatracker.ietf.org/doc/html/rfc4514#section-2.1>
says that sequence is converted to a string in the reverse order, "starting
with the last element of the sequence and moving backwards towards the first".

So a DN represented as a string "ST = California, C = US" would be in the
proper order, because the `countryName` would normally be seen as a parent to
the `stateOrProvinceName`.

What I find that seems to work in practice in OpenSSL, though, is the reverse
of that expected representation.  For example, if I define a
`distinguished_name` section in a config file as:

  distinguished_name = req_distinguished_name
  
  [ req_distinguished_name ]
  C  = US
  ST = California
  CN = foo

and in the CA config, a name constraint:

  nameConstraints = critical, @name_constraints
  
  [ name_constraints ]
  permitted;dirName = dir_section
  
  [ dir_section ]
  C  = US
  ST = California

the certificate chain verifies.  But not if I reverse the order of all the
RDN lines.

Is this correct as is?  Is it a known issue?  The manual pages don't really
talk about it.  I'm not familiar with the historical LDAP usages.

-- 
You received this message because you are subscribed to the Google Groups "openssl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openssl-users+unsubscribe-MCmKBN63+Bmbup2nOX2J7Q@public.gmane.org
To view this discussion visit https://groups.google.com/a/openssl.org/d/msgid/openssl-users/aIlI2T7Trb6TbqLV%4070-36-235-101.dsl.static.fusionbroadband.com.