Does an alternative to System.Security.Cryptography.Pkcs.SignedCms class exist in .NET Core? Or do I have to dig into BouncyCastle, like they do in WinRT case? Is there an alternative of SignedCMS in WinRT?
NET Core 3.0 uses OpenSSL 1.1.
The SignedCms class enables signing and verifying of CMS/PKCS #7 messages.
.NET Core currently lacks SignedCms support which is available in standard .NET Framework. http://stackoverflow.com/questions/40918396/signedcms-alternative-in-net-core/40954173#40954173
.NET Core version 2.2 and earlier: No signer certificate was provided. This method succeeds if SubjectIdentifierType.NoSignature was provided as the signerIdentifierType argument of one of the SignedCms constructor overloads. Otherwise, it throws an exception. The following permissions are required to access the signature key:
In .NET Framework, the silent parameter of the SignedCms.ComputeSignature (CmsSigner, Boolean) method is ignored, and a PIN prompt is always shown if required by the provider. In .NET Core, the silent parameter is respected, and if set to true, a PIN prompt is never shown, even if it's required by the provider.
.NET Framework (all versions) and .NET Core 3.0 and later: The recipient certificate is not specified. .NET Core version 2.2 and earlier: No signer certificate was provided.
FYI in case it helps. It seems that support for SignedCms and other essential .NET classes for S/MIME are available via this NUGET
package:
System.Security.Cryptography.Pkcs
I.e. before I added this NUGET
package to my Visual Studio 2017 (VS2017) .NET Core project, I received these compilation errors:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'CmsRecipientCollection' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'X509IssuerSerial' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'EnvelopedCms' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'SignedCms' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'SignerInfoCollection' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'ContentInfo' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'CmsRecipient' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'RecipientInfo' could not be found (are you missing a using directive or an assembly reference?)
Error CS0103 The name 'SubjectIdentifierType' does not exist in the current context
Error CS0246 The type or namespace name 'SignerInfo' could not be found (are you missing a using directive or an assembly reference?)
Error CS1579 foreach statement cannot operate on variables of type 'SignerInfoCollection' because 'SignerInfoCollection' does not contain a public instance definition for 'GetEnumerator'
Error CS0246 The type or namespace name 'CmsSigner' could not be found (are you missing a using directive or an assembly reference?)
After I added the NUGET
package, I could compile successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With