我有一个证书,我需要使用它才能访问 Web 服务。问题是每当我尝试使用 X509 证书时,它都会要求输入密码 (PIN)。有没有办法直接提供密码,而不是每次都弹出同一个窗口?
该证书使用 Oberthur Technologies 制造的加密狗,如果有帮助的话。这是我用来获取证书的代码:
X509Store store = new X509Store("MY",StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
if(collection.Count != 0)
userCert = collection[0]; // everything's ok up to here
这是我使用证书的地方:
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(url));
req.ClientCertificates.Add(userCert); // add the certificate I just got
// ...
WebResponse ret = req.GetResponse(); // here's where it asks me for my passphrase