I'm trying to use a WCF api with .Net Core 2.1.2, but I'm currently facing some issues with certified validations.
The main problem is, when I'm DEBUGGING I can make requests against the server. When I deploy a executable file of my project and run in my machine, I can make requests either. But, when I copy the same executable to the acceptance environment, the code throws an exception "could not establish trust relationship for the SSL/TLS secure channel"
My machine is outside of the acceptance environment (I'm using a VPN). The acceptance machine is inside the environment.
Any ideas of what is going on ?
Thanks !
private WSClient InstantiateProxy()
{
WSClient accessWSClient = new WSClient(EndpointConfiguration.MIAccessPort, Configuration["AppConfiguration:Endpoint"]);
accessWSClient.ClientCredentials.Windows.ClientCredential =
new NetworkCredential(Configuration["AppConfiguration:Username"], Configuration["AppConfiguration:Password"]);
ConfigureBinding(accessWSClient);
accessWSClient.ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new X509ServiceCertificateAuthentication
{
CertificateValidationMode = X509CertificateValidationMode.None,
RevocationMode = X509RevocationMode.NoCheck,
};
return accessWSClient;
}
private static void ConfigureBinding(WSClient accessWSClient)
{
System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding
{
MaxBufferSize = int.MaxValue,
ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max,
MaxReceivedMessageSize = int.MaxValue,
AllowCookies = true
};
binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
accessWSClient.Endpoint.Binding = binding;
}