[Mono-list] cryptografy with Mono - works with DOTNET, fails with MONO

Sebastien Pouliot sebastien.pouliot at gmail.com
Wed Mar 9 09:22:41 EST 2011


Not 100% sure, PKCS7 is quite large.

Mono.Security.dll provides some (very low level) API do that support
some formats (e.g. it's used for authenticode signatures). It's
low-level enough to allow you to do anything (including a lot of
things what won't interoperate if you make mistakes ;-)

Otherwise I would suggest you look at using Bouncycastle (the .net
version of course :-)

Sebastien

Le 2011-03-09 à 09:12, Diego Diego <diego_cai at hotmail.com> a écrit :

>
> OK. Thanks Sebastien!
>
> Do you know any library to write an alternative code and solve this problem? I must sign data in a PKCS#7 format.
>
>
>
> Diego
> Cambiá a Linux !!
>
>
>
>
>
>
>
> ----------------------------------------
>> From: sebastien.pouliot at gmail.com
>> Date: Tue, 8 Mar 2011 08:29:26 -0500
>> Subject: Re: [Mono-list] cryptografy with Mono - works with DOTNET, fails with MONO
>> To: tym.majewski at nearmap.com
>> CC: diego_cai at hotmail.com; mono-list at lists.ximian.com
>>
>> Diego,
>>
>> The System.Security.Cryptography.Pkcs namespace was never completed.
>> Some stuff will work, others wont. Some missing features would require
>> only a bit of work, others would require a lot.
>>
>> Please fill a bug report including a self-contained test case.
>>
>> Sebastien
>>
>> Le 2011-03-07 à 20:32, Tymek Majewski  a écrit :
>>
>>> On Fri, Mar 4, 2011 at 12:24 AM, diegocairone  wrote:
>>>> I have a problem running this code under Mono. The same code works OK under
>>>> DOTNET. What can I do?
>>>>
>>>> X509Certificate2 crt = new X509Certificate2();
>>>>
>>>> byte[] crtBytes = [ certificate in the format PKCS12 (certificate + private
>>>> key) obtained using FileStream class]
>>>>
>>>> crt.Import(crtBytes, "123456", X509KeyStorageFlags.DefaultKeySet);
>>>>
>>>> Encoding msgCodificado = Encoding.UTF8;
>>>> byte[] msgBytes = msgCodificado.GetBytes(xmlTRA.OuterXml); //
>>>> xmlTRA.OuterXml is the data to sign
>>>>
>>>> ContentInfo pkcsContentInfo = new ContentInfo(msgBytes);
>>>> SignedCms cms = new SignedCms(pkcsContentInfo);
>>>> CmsSigner firmante = new CmsSigner(crt);
>>>>
>>>> firmante.IncludeOption = X509IncludeOption.EndCertOnly;
>>>> cms.ComputeSignature(firmante); // ---> throw an cryptografy exception with
>>>> MONO
>>>>
>>>> byte[] firma = cms.Encode();
>>>> firmaB64 = Convert.ToBase64String(firma);
>>>>
>>>> I am using using:
>>>> System.Text;
>>>> using System.Security.Cryptography;
>>>> using System.Security.Cryptography.Pkcs;
>>>> using System.Security.Cryptography.X509Certificates;
>>>>
>>>> What can I do?
>>>> Thanks.
>>>
>>> Hi,
>>>
>>> If you post which version of Mono you used and exactly what the
>>> exception was (with the stack trace) you will get a meaningful answer
>>> quicker:)
>>>
>>>
>>> Cheers,
>>> Tymek Majewski
>>> _______________________________________________
>>> Mono-list maillist - Mono-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-list
>


More information about the Mono-list mailing list