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

diegocairone diego_cai at hotmail.com
Thu Mar 3 11:24:01 EST 2011


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.


--
View this message in context: http://mono.1490590.n4.nabble.com/cryptografy-with-Mono-works-with-DOTNET-fails-with-MONO-tp3333661p3333661.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list