Create copies of mutable properties on X509Certificate2
authorKevin Jones <kevin@vcsjones.com>
Fri, 10 Jul 2020 15:26:54 +0000 (11:26 -0400)
committerGitHub <noreply@github.com>
Fri, 10 Jul 2020 15:26:54 +0000 (08:26 -0700)
commiteda20d006dddb6e6e38c1b1139893472321b9d25
tree6e444f7b1cf9593ad74a5e4b9d4cc1786fcb4878
parent4dccf9a5e1127f8be192b6b9b2f102138d620f6d
Create copies of mutable properties on X509Certificate2

Export(Cert) returned the original byte array from the PAL. If a
caller mutated the result of the export, they would be mutating the
underlying representation of RawData in the PAL. To be consistent
with Windows and Linux, we return a copy in the PAL.

Fix OpenSSL PAL to prevent side effects between mutable
SubjectName.RawData and Subject properties (similarly for Issuer)
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/CertificateData.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs
src/libraries/System.Security.Cryptography.X509Certificates/tests/CertTests.cs
src/libraries/System.Security.Cryptography.X509Certificates/tests/ExportTests.cs