Open bartonjs opened 5 months ago
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones See info in area-owners.md if you want to be subscribed.
I think the part that will help guide a decision here is how the behavior matches with GetCertContentType
. In .NET, that's easy, we can just make GetCertContentType
do whatever we want it to do.
In .NET Framework, we can't change that behavior. It would be weird for GetCertContentType
to say "I don't know what that is" but the loader loads it anyway. Or the opposite, where GetCertContentType
says "This is a X.509 certificate" and the loader says "I cannot load that".
With that in mind, I would want the answer to be "Do what Windows does". Some experimentation shows that Windows PEM reader just looks for PEM encapsulation boundaries regardless of surrounding data. That said, my proposal would be
Base64
class to do all of the Base64 reading and validation. The version used in M.B.C will need to be an older version of PemEncoding that carries its own Base64 validation.
The new certificate loader tests have shown some platform differences in corner cases when it comes to PEM-encoded contents.
-----END CERTIFICATE-----text
, but Linux/OpenSSL requires a newline between the 5th hyphen and subsequent text.-----END CERTIFICATE-----\n<binary data>
, but macOS does not.Pros:
Cons:
BIO_new_file
to try both DER and PEM, unifying requires having the contents available for inspection in managed code; either after the DER load fails, or switching to a "memory only" interaction with OpenSSL and not doing file-based work at all.-----END CERTIFICATE-----text
is currently not permitted by our PemEncoding class.