package x509

  1. Overview
  2. Docs

X.500 distinguished name

type attribute =
  1. | CN of string
  2. | Serialnumber of string
  3. | C of string
  4. | L of string
  5. | ST of string
  6. | O of string
  7. | OU of string
  8. | T of string
  9. | DNQ of string
  10. | Mail of string
  11. | DC of string
  12. | Given_name of string
  13. | Surname of string
  14. | Initials of string
  15. | Pseudonym of string
  16. | Generation of string
  17. | Street of string
  18. | Userid of string
  19. | Other of Asn.oid * string

The variant of a relative distinguished name component, as defined in X.500: an attribute type and value.

Relative_distinguished_name is a set of attributes.

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

val equal : t -> t -> bool

equal a b is true if the distinguished names a and b are equal.

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.

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 -> string option

common_name t is Some x if the distinguished name t contains a CN x, None otherwise.

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

decode_der cs is dn, the ASN.1 decoded distinguished name of cs.

val encode_der : t -> string

encode_der dn is octets, the ASN.1 encoded representation of the distinguished name dn.

OCaml

Innovation. Community. Security.