apple / swift-certificates

An implementation of X.509 for Swift
https://swiftpackageindex.com/apple/swift-certificates/main/documentation/x509
Apache License 2.0
223 stars 53 forks source link

Simplify the internal representation of `RDN.Attribute.Value` #156

Closed dnadoba closed 10 months ago

dnadoba commented 10 months ago

Motivation

The 1.1.0 release included a patch (#154) that supported converting RDNAttribute values into strings. This patch missed that the .any case may also have strings in it.

While investigating this limitation, @Lukasa realised that the constructor function was excessively complex. While it attempted to coerce based on extra information in the ASN.1 specification, it always fell back into the .any case. This meant that as a practical matter we always took the same few paths, and so could safely simplify the code.

Modifications

Result

Faster construction, normalised representation, less code.

Lukasa commented 10 months ago

@dnadoba you have a soundness issue that needs to be resolved.