c# - The request was aborted: Could not create SSL/TLS secure channel Exception -
let me explain situation.
i created self-signed certificate , installed in trusted root certification authorities section in mmc.
i created 2 certificates using self-signed certificate:
- a certificate subject name "localhost"
- a certificate subject name "test.com"
i installed both certificates personal certificates section in mmc.
i deployed web service https (ssl accept client certificates) in iis. certificate used deploy web service 1 subject name "localhost".
now, have client wants connect web service. added web reference service. code:
clientservices web_service = new clientservices(); x509store store = new x509store(storename.my, storelocation.localmachine); store.open(openflags.readonly); x509certificate2collection col = store.certificates.find(x509findtype.findbysubjectname, "test.com", true); if (col.count == 1) { servicepointmanager.expect100continue = true; servicepointmanager.securityprotocol = securityprotocoltype.ssl3 | securityprotocoltype.tls; web_service.clientcertificates.add(col[0]); try { string hello = web_service.helloworld(); int add = web_service.add(4, 31); int sub = web_service.subtract(30, 10); console.writeline(hello); console.writeline(add); console.writeline(sub); } catch (webexception e) { console.writeline(e.message.tostring()); } } else { console.writeline("the certificate not found!"); } console.readkey();
as can see, sending "test.com" certificate along web service request. unfortunately, getting exception:
the request aborted: not create ssl/tls secure channel
how can solve problem? have wasted 3 hours on issue. please me.
private void somewhere() { servicepointmanager.servercertificatevalidationcallback += new remotecertificatevalidationcallback(allwaysgoodcertificate); } private static bool allwaysgoodcertificate(object sender, x509certificate certificate, x509chain chain, sslpolicyerrors policyerrors) { return true; }
source: the request aborted: not create ssl/tls secure channel