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

Tymek Majewski tym.majewski at nearmap.com
Mon Mar 7 20:31:59 EST 2011


On Fri, Mar 4, 2011 at 12:24 AM, diegocairone <diego_cai at hotmail.com> 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


More information about the Mono-list mailing list