Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignedCms alternative in .NET Core

Tags:

c#

.net-core

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?

like image 551
Alex Avatar asked Dec 01 '16 18:12

Alex


People also ask

Does .NET core use OpenSSL?

NET Core 3.0 uses OpenSSL 1.1.

What is SignedCms?

The SignedCms class enables signing and verifying of CMS/PKCS #7 messages.

Does NET Core support signed CMS?

.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

Is there a signer certificate available for signedcms?

.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:

What is the silent parameter of the signedcms method?

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.

Which version of the NET Framework has a signer certificate?

.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.


1 Answers

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.

like image 192
moosewall Avatar answered Sep 21 '22 04:09

moosewall