Skip to content

Support building DistinguishedName from RFC 4514 input #200

Description

@natevw

It would be helpful if DistinguishedName (and perhaps its subcomponents?) could support initialization from RFC 4514–formatted strings.

RelativeDistinguishedName.Attribute and its .Value have a rough sort of reverse form of this in

public var description: String {
let attributeKey: String
switch self.type {
case .RDNAttributeType.commonName:
attributeKey = "CN"
case .RDNAttributeType.countryName:
attributeKey = "C"
case .RDNAttributeType.localityName:
attributeKey = "L"
case .RDNAttributeType.stateOrProvinceName:
attributeKey = "ST"
case .RDNAttributeType.organizationName:
attributeKey = "O"
case .RDNAttributeType.organizationalUnitName:
attributeKey = "OU"
case .RDNAttributeType.streetAddress:
attributeKey = "STREET"
case let type:
attributeKey = String(describing: type)
}
return "\(attributeKey)=\(value)"
}
and https://github.com/apple/swift-certificates/blob/a846fc71499526eeceae5e3b739235ff249d4433/Sources/X509/RDNAttribute.swift#L148C46-L150 and this is highlighted in the docs
A string representation of a ``DistinguishedName`` can be obtained by using `String(describing:)`. This
uses the common [RFC4514 format](https://www.rfc-editor.org/rfc/rfc4514) for textual ``DistinguishedName``s.
as following the standard, but there is currently no parsing/deserialization offered in the other ddirection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions