[Mono-dev] Version Number: Bug in Mono with PKCS12 Certificates?

matthieu Barthélemy bonsouere at gmail.com
Sun May 12 07:20:59 UTC 2013

Hi Munawar,

On Sun, May 12, 2013 at 8:13 AM, Munawar Bijani <munawarb at gmail.com> wrote:

>   Hi Everyone,
> I have a crt file and key file which I’ve merged into a pkcs12 file using
> OpenSSL on Linux. When I load this file into the X509Certificate2 object, I
> get an error: Unabel to decode certificate. I’m loading the certificate
> using the X509Certificate2.Import(String) method provided in .NET.

I have a personal project under mono which make extensive use of pkcs12
certificates. So I can confirm mono is able to load a certificate generated
with Openssl (or own-generated, or using makecert). Note that you're using
a really old Mono (2.6.7), could you try with a 2.10.x version?

I just did a test to confirm, and using this openssl command:

 openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout
certificate_temp.key -out certificate_temp.crt

p2pb at linux-33v9:~/Node/bin/Debug> ls
certificate_temp.key    certificate_temp.crt    Node.exe

p2pb at linux-33v9:~/Node/bin/Debug> openssl pkcs12 -export -out
certificate_temp.pfx -inkey certificate_temp.key -in certificate_temp.crt
Enter Export Password: [left blank in my test]
Verifying - Enter Export Password:

p2pb at linux-33v9:~/Node/bin/Debug> ls
certificate_temp.key Node.exe     certificate_temp.crt

I use the following code to load my certificates:
X509Certificate2 cert = new
X509Certificate2("~/Node/bin/Debug/certificate_temp.pfx", "");
keyPair =  (RSACryptoServiceProvider)cert.PrivateKey;

> The interesting thing is, when I issue:
> X509Certificate2.GetCertContentType(“server.p12”);, the output is correct:
> PKCS12.
> I’m on Debian with Mono 2.0.67 I think is the build. Is this a problem
> with Mono or am I doing something incorrect when importing my PKCS12
> certificate? Thanks much!
> Munawar
> munawarb at gmail.com
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130512/cd854194/attachment.html>

More information about the Mono-devel-list mailing list