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
It would be helpful if
DistinguishedName(and perhaps its subcomponents?) could support initialization from RFC 4514–formatted strings.RelativeDistinguishedName.Attributeand its.Valuehave a rough sort of reverse form of this inswift-certificates/Sources/X509/RDNAttribute.swift
Lines 211 to 233 in a846fc7
swift-certificates/Sources/X509/Docs.docc/Examining Certificates.md
Lines 65 to 66 in a846fc7