package x509

  1. Overview
  2. Docs

Module X509.Distinguished_nameSource

X.500 distinguished name

module Encoded_string : sig ... end

ASN.1 string contents and encoding.

module type Attribute_value = sig ... end

Attribute values with encoding-specific constructors. String repertoires and attribute-specific length bounds are not checked.

The module type for common name.

module Serial_number : Attribute_value with type encoding = [ `Printable ]

The module type for serial number.

module Country_name : Attribute_value with type encoding = [ `Printable ]

The module type for country name.

The module type for locality name.

The module type for state or province name.

The module type for organization name.

The module type for organization unit name.

The module type for title.

module Email_address : Attribute_value with type encoding = [ `IA5 ]

The module type for email address.

Values used by givenName, surname, initials and generationQualifier.

The module type for pseudonym.

The module type for street address.

The module type for user id.

module Other_attribute : sig ... end

Attributes whose OIDs have no named constructor.

type attribute =
  1. | CN of Common_name.t
  2. | Serialnumber of Serial_number.t
  3. | C of Country_name.t
  4. | L of Locality_name.t
  5. | ST of State_or_province_name.t
  6. | O of Organization_name.t
  7. | OU of Organizational_unit_name.t
  8. | T of Title.t
  9. | DNQ of [ `Printable ] Encoded_string.t
  10. | Mail of Email_address.t
  11. | DC of [ `IA5 ] Encoded_string.t
  12. | Given_name of Personal_name.t
  13. | Surname of Personal_name.t
  14. | Initials of Personal_name.t
  15. | Pseudonym of Pseudonym.t
  16. | Generation of Personal_name.t
  17. | Street of Street_address.t
  18. | Userid of User_id.t
  19. | Other of Other_attribute.t

An X.500 attribute type and value.

A set of attributes. String encodings participate in comparison.

A distinguished name is a list of relative distinguished names, starting with the most significant component.

val equal : t -> t -> bool

equal a b compares the stored RDN sequences, including the string encodings and content octets of their attributes.

val matches : t -> t -> bool

matches a b compares names using a restricted byte-based matching rule. Attribute types, RDN order and stored attribute counts must agree. For known DirectoryString attributes, PrintableString and UTF8String values with identical content octets match. Other encodings and unknown attributes require identical string tags and content octets.

This does not implement the StringPrep processing of RFC 5280 section 7.1: no case folding, whitespace normalization or transcoding is performed.

val make_pp : format:[ `RFC4514 | `OpenSSL | `OSF ] -> ?spacing:[ `Tight | `Medium | `Loose ] -> unit -> t Fmt.t

make_pp () creates a customized pretty-printer for t.

  • parameter format

    Determines RDN order, escaping rules, and the default spacing:

    • `RFC4514 produces the RFC4514. RDNs are written in reverse order of the ASN.1 representation and spacing defaults to tight.
    • `OpenSSL produces the a format similar to OpenSSL. RDNs are written in the order of the ASN.1 representation, and spacing defaults to loose.
    • `OSF emits RDNs in the order they occur in the ASN.1 representation, each prefixed by a slashes, using tight spacing. This format is designed by analogy to RFC4514, substituting slash for comma an semicolon, and may currently not be fully compliant with the OSF specifications.
  • parameter spacing

    Determines whether to add space around separators:

  • `Tight to not add any redundant space,
  • `Medium to add space after comma and around plus signs, and
  • `Loose to also add space around equality signs.

This parameter is currently ignored for the OSF format.

The pretty-printer can be wrapped in a box to control line breaking and set it apart, otherwise the RDN components will flow with the surrounding text. String contents are not transcoded, and encoding tags are omitted.

val pp : t Fmt.t

pp ppf dn pretty-prints the distinguished name. This is currently Fmt.hbox (make_pp ~format:`OSF ()). If your application relies on the precise format, it is advicable to create a custom formatter with make_pp to guard against future changes to the default format.

val common_name : t -> Common_name.t option

common_name t is a CN value from the most specific RDN containing one, or None if t has no CN.

val decode_der : string -> (t, [> `Msg of string ]) result

decode_der cs is dn, the ASN.1 decoded distinguished name of cs. Known attributes must use their permitted string types. String contents are decoded using the ASN.1 string primitives, without additional repertoire or character-count checks.

val encode_der : t -> string

encode_der dn is octets, the ASN.1 encoded representation of the distinguished name dn. String encodings and content octets are preserved.