mirror of
https://github.com/apple/swift-certificates
synced 2026-11-24 04:27:49 +00:00
When we decode a certificate, we produce an in-memory representation. This representation is something we are capable of encoding. If we re-encode that directly, we can produce an output that is different to the one we injested. This happens when there are objects that can be canonicalised, such as replacing an explicit ASN1 NULL with an absent field where both are considered equivalent. This patch rewrites the code to ensure that we preserve the bytes of the certificate that we deserialized. This allows us to write them back unchanged, ensuring that certificates can round-trip through this library without modification. A side-effect of this change is that we need to essentially encode the certificate on construction whenever we build them in memory. That's not a big deal, but it is a bit of an annoyance.