I'm porting an app that uses a System.Net.HttpWebRequest with client 
certificates, and I've found that I can't seem to create a 
System.Security.Cryptography.X509Certificates.X509Certificate2 from a 
serialized PKCS#12 byte[].   I've created the byte[] using Bouncycastle's 
Pkcs12Store.Save() method, and creating an X509Certifcate2 object from this 
seems to work fine in windows (using the byte[] constructor).  With monodroid 
though I get an exception when constructing:

byte[] bits = .... Pkcs#12 stuff ...
X509Certificate2 foo = new X509Certificate2(bits);

System.Security.Cryptography.CryptographicException: Unable to decode 
certificate. ---> System.Security.Cryptography.CryptographicException: Input 
data cannot be coded as a valid certificate. ---> System.NotSupportedException: 
Undefined length encoding.

The comment "Note: this feature is working only on the 2.0 profile since Mono 
version 1.2.5. It is mandatory that the new X509Certificate2 class be used to 
load a format that contains a private key (e.g. a PKCS#12 file)." here: 
http://www.mono-project.com/UsingClientCertificatesWithXSP makes it sound like 
PKCS#12 support is a relatively new addition, and perhaps hasn't hit monodroid 
yet?

Anyone using System.Net.HttpWebRequest (or something similar) with a site that 
requires client certificates? Any other ways to create an X509Certificate2 with 
a private key so it can be used this way?

Thanks,
Nate


_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to