C# https ssl answer with certificate -
hy, wanna access programmatically web page in web browser control asks certificate. never worked certificates till know how search in //user// personal certificates , give it. don't know if must pass it's password or not. give me clues? in advance.
edit: till have solution getting answer:
private void button2_click(object sender, eventargs e) { x509certificate2 certificate = new x509certificate2("d:\\mycert.pfx", "certpass"); //validation of ssl //avoid certificate problems servicepointmanager.servercertificatevalidationcallback += new system.net.security.remotecertificatevalidationcallback(validateservercertificate); //send request httpwebrequest request = (httpwebrequest)webrequest.create("https://www.example.com"); request.clientcertificates.add(certificate); //get response httpwebresponse response = (httpwebresponse)request.getresponse(); response.close(); } //map server related errors. private static bool validateservercertificate(object sender, x509certificate certificate, x509chain chain, sslpolicyerrors policyerrors) { return true; }
it accepts certificate ok want web-browser control navigate url , attach certificate internally, won´t ask certificate anymore , load page want.
Comments
Post a Comment