c#调用SSL

http://xwhoyeah.iteye.com/blog/101314
  1. X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
  2. store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
  3. X509Certificate2Collection certs = X509Certificate2UI.SelectFromCollection(store.Certificates, "Certificates", "Please select certificate to use", X509SelectionFlag.SingleSelection);
  4. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://localhost:8443/axis/");
  5. request.ClientCertificates.Add(certs[0]);
  6. request.KeepAlive = true;
  7. request.Method = "POST";
  8. request.ContentType = "text/xml";
  9. request.KeepAlive = true;
  10. HttpWebResponse res = (HttpWebResponse)request.GetResponse();
  11. StreamReader sr = new StreamReader(res.GetResponseStream());
  12. MessageBox.Show(sr.ReadToEnd());
posted @ 2012-07-16 20:42  adodo1  Views(240)  Comments(0Edit  收藏  举报