|
| 1 | +--- |
| 2 | +title: "Breaking change - APIs Removed from System.Security.Cryptography.Pkcs netstandard2.0" |
| 3 | +description: "Learn about the breaking change in .NET 9 where certain APIs were removed from System.Security.Cryptography.Pkcs netstandard2.0." |
| 4 | +ms.date: 3/11/2025 |
| 5 | +ai-usage: ai-assisted |
| 6 | +ms.custom: https://github.com/dotnet/docs/issues/45186 |
| 7 | +--- |
| 8 | + |
| 9 | +# APIs Removed from System.Security.Cryptography.Pkcs netstandard2.0 |
| 10 | + |
| 11 | +The `netstandard2.0` build of the `System.Security.Cryptography.Pkcs` NuGet package versions 9.0.0 through 9.0.2 included APIs that are not present in .NET Framework. Calling these APIs from a .NET Standard library that runs on .NET Framework will throw <xref:System.MissingMemberException>. These members were mistakenly included and have been removed in version 9.0.3 of the package. |
| 12 | + |
| 13 | +## Version introduced |
| 14 | + |
| 15 | +.NET 9 |
| 16 | + |
| 17 | +## Previous behavior |
| 18 | + |
| 19 | +When referencing `System.Security.Cryptography.Pkcs` version 9.0.0 in a project targeting `netstandard2.0`, the compilation would succeed when referencing the <xref:System.Security.Cryptography.Pkcs.CmsSigner.PrivateKey?displayProperty=nameWithType> property. However, if the library ran on .NET Framework, accessing the property would trigger a <xref:System.MissingMemberException>. |
| 20 | + |
| 21 | +## New behavior |
| 22 | + |
| 23 | +Accessing any of the removed members now results in a compilation failure, rather than a runtime failure. |
| 24 | + |
| 25 | +## Type of breaking change |
| 26 | + |
| 27 | +This is a [source incompatible](../../categories.md#source-compatibility) change. |
| 28 | + |
| 29 | +## Reason for change |
| 30 | + |
| 31 | +The members were accidentally included due to a change in how the NuGet package was produced. As these members cannot work on .NET Framework, they should never have been listed as available to .NET Standard 2.0. |
| 32 | + |
| 33 | +## Recommended action |
| 34 | + |
| 35 | +If these additional members are needed, compile specifically for a TFM that includes them, such as `net8.0`. |
| 36 | + |
| 37 | +## Affected APIs |
| 38 | + |
| 39 | +- <xref:System.Security.Cryptography.Pkcs.CmsSigner.%23ctor*> |
| 40 | +- <xref:System.Security.Cryptography.Pkcs.CmsSigner.PrivateKey?displayProperty=fullName> |
| 41 | +- <xref:System.Security.Cryptography.Pkcs.CmsSigner.SignaturePadding?displayProperty=fullName> |
| 42 | +- <xref:System.Security.Cryptography.Pkcs.ContentInfo.GetContentType(System.ReadOnlySpan{System.Byte})?displayProperty=fullName> |
| 43 | +- <xref:System.Security.Cryptography.Pkcs.EnvelopedCms.Decode(System.ReadOnlySpan{System.Byte})?displayProperty=fullName> |
| 44 | +- <xref:System.Security.Cryptography.Pkcs.EnvelopedCms.Decrypt(System.Security.Cryptography.Pkcs.RecipientInfo,System.Security.Cryptography.AsymmetricAlgorithm)?displayProperty=fullName> |
| 45 | +- <xref:System.Security.Cryptography.Pkcs.SignedCms.AddCertificate(System.Security.Cryptography.X509Certificates.X509Certificate2)?displayProperty=fullName> |
| 46 | +- <xref:System.Security.Cryptography.Pkcs.SignedCms.Decode(System.ReadOnlySpan{System.Byte})?displayProperty=fullName> |
| 47 | +- <xref:System.Security.Cryptography.Pkcs.SignedCms.RemoveCertificate(System.Security.Cryptography.X509Certificates.X509Certificate2)?displayProperty=fullName> |
| 48 | +- <xref:System.Security.Cryptography.Pkcs.SignerInfo.AddUnsignedAttribute(System.Security.Cryptography.AsnEncodedData)?displayProperty=fullName> |
| 49 | +- <xref:System.Security.Cryptography.Pkcs.SignerInfo.SignatureAlgorithm?displayProperty=fullName> |
| 50 | +- <xref:System.Security.Cryptography.Pkcs.SignerInfo.GetSignature?displayProperty=fullName> |
| 51 | +- <xref:System.Security.Cryptography.Pkcs.SignerInfo.RemoveUnsignedAttribute(System.Security.Cryptography.AsnEncodedData)?displayProperty=fullName> |
| 52 | +- <xref:System.Security.Cryptography.Pkcs.SubjectIdentifier.MatchesCertificate(System.Security.Cryptography.X509Certificates.X509Certificate2)?displayProperty=fullName> |
0 commit comments