c# error when calling a wcf service in localhost: Info:System.Net.WebException: The…
- User
c# error when calling a wcf service in localhost: Info:System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream()
Assistant
This error typically occurs when trying to make a secure connection (HTTPS) to a WCF service but there are SSL/TLS configuration issues. Here are the common solutions:
- Add this code before making the service call:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;- If you're using a self-signed certificate for local development, you can bypass certificate validation (only for development!):
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;- Check your service binding configuration in web.config. Make sure the security mode matches your setup:
<bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IService"> <security mode="Transport"> <transport clientCredentialType="None"/> </security> </binding> </basicHttpBinding> </bindings>- If you don't need HTTPS for local development, you can change your service URL from "https://" to "http://"
Would you like me to explain any of these solutions in more detail?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.