This error typically occurs when there's an issue with SSL/TLS configuration when trying to call a WCF service on localhost. Here are several potential solutions:
- Disable SSL Certificate Validation (for development only):
// Add this before calling the service
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate { return true; };
- Check SSL/TLS Protocol Settings:
System.Net.ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls;
- Verify Binding Configuration:
In your app.config or web.config, ensure the binding is correctly configured:
<bindings>
<basicHttpBinding>
<binding name="YourBindingName">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
- Common Causes:
- Mismatched SSL/TLS protocols
- Self-signed certificates
- Incorrect security settings in WCF service
- Firewall or network restrictions
- Troubleshooting Steps:
- Verify the service is running correctly
- Check if you can access the service via browser
- Ensure all security settings match between client and service
- Temporarily disable security for testing (only in development)
If the issue persists, you'll need to provide more details:
- Full exception stack trace
- Service configuration
- Client configuration
- .NET Framework version
Remember, disabling SSL validation is only acceptable in local development environments and should never be used in production.