First, import the certificate
1. Click Start, click Run, type mmc, and then click OK.
2. On the File menu, click Add/Remove Snap-in.
3. Select the certificate in the list of available snap-in and click Add.
4. Select the computer account in the Certificate Management dialog box and click Next
5. In the Select Computer dialog box, click Finish.
6. In the Add or Remove Snap-in dialog box, click OK.
7. Expand Certificates (Local computer), expand Personal, and then click Certificates.
8. Right button-"All Tasks-" Import Select your certificate import
II. Installation of Authorization tools
1. Download WinHttpCertCfg.exe Installation
2. After installation, use the command window to jump to C:\Program files\windows Resource kits\tools execute winhttpcertcfg-g-C local_machine\my- S "Your certificate name"-A "EVERYONE"
Third, use the imported certificate in the code
//Create an HTTP request
HttpWebRequest HttpRequest = (HttpWebRequest) httpwebrequest.create (strURL);
Servicepointmanager.expect100continue = true;
Servicepointmanager.securityprotocol = SECURITYPROTOCOLTYPE.SSL3;
//to add a callback method for validating a certificate
Servicepointmanager.servercertificatevalidationcallback =
(ObjectSender, X509Certificate certificate, X509chain chain, sslpolicyerrors sslpolicyerrors) = {returntrue; };
//find a system-imported certificate
X509store Certstore =NewX509store (storename.my, storelocation.localmachine);
Certstore.open (openflags.readonly);
X509Certificate2Collection certcollection = CertStore.Certificates.Find (X509findtype.findbysubjectname,"Test",false);
//to add a certificate to the request objectHTTPREQUEST.CLIENTCERTIFICATES.ADD (certcollection[0]);
Request code slightly ...
IIS7 "Request aborted: Failed to create SSL/TLS secure channel" workaround