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