Fix PKCS7 export quirks.
authorKevin Jones <kevin@vcsjones.com>
Fri, 24 Sep 2021 16:31:35 +0000 (12:31 -0400)
committerGitHub <noreply@github.com>
Fri, 24 Sep 2021 16:31:35 +0000 (09:31 -0700)
commit3d4fac06b6cc3e80a03e9571eac54e9964c3cc42
tree9390f7d10cfb3399beccbe01183fbf893de2bbca
parent8f12df6f3f39ea2bedf6c222664720a48c03c599
Fix PKCS7 export quirks.

On macOS, exporting an empty X509Certificate2Collection to PKCS7 would
produce an exception. Instead, we return a pre-encoded empty PKCS7
result.

On Windows, the PKCS7 export would include trailing zeros in PKCS7
export. This occured because the first calls to CertSaveStore would
return a size that is at least big enough, but not exact. This trims the
result to the actual amount written on the second call.
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/StorePal.ExportPal.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Export.cs
src/libraries/System.Security.Cryptography.X509Certificates/tests/CollectionTests.cs