Specify client certificates in HttpWebRequest in .NET Compact Framework 3.5
Previously, I was trying to use client certificate on .NET CF 2.0 (see here) and I ultimately had to give up. I'm now on .NET CF 3.5 which has support for the ClientCertificates
property on the HttpWebRequest
object. However, I can't figure out how to instantiate the 开发者_运维知识库X509Certificate
or X509Certificate2
object with a pfx file. On the full framework, I can simply do something like new X509Certificate2(filename, password)
. If I try to create the object with bytes read from a .pfx file, I get an exception saying ".NET CF 3.5 does not support pfx files". So how do I specify a client certificate with a private key for use with the ClientCertificates
property?
According to MDSN there are only 2 contructors available/supported by the compact framework:
http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.x509certificate2.aspx
The .NET CF supported constructors have a little device icon next to them in the first column.
These are:
X509Certificate2(array<Byte>[]()[])
http://msdn.microsoft.com/en-us/library/ms148413.aspx
X509Certificate2(IntPtr)
http://msdn.microsoft.com/en-us/library/ms148414.aspx
精彩评论