Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building DistinguishedName from RFC 4514 input #200

Open
natevw opened this issue Sep 24, 2024 · 1 comment
Open

Support building DistinguishedName from RFC 4514 input #200

natevw opened this issue Sep 24, 2024 · 1 comment

Comments

@natevw
Copy link

natevw commented Sep 24, 2024

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

@Lukasa
Copy link
Contributor

Lukasa commented Sep 25, 2024

Yeah, this sounds like a reasonable feature. I'd be happy to see someone take a swing at implementing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants