Ошибка: < /p>
Исключение < /strong> < /em> не могло быть обработан. ' отредактированный < /strong> < /em>' неверен или потому что сообщение содержит недопустимый или истекший токен контекста безопасности или потому, что между привязками есть несоответствие. Привязка конечной точки. < /p>
< /blockquote>
Это мой код: < /p>
Код: Выделить всё
public Service1Client GetSoapClient()
{
string address = _configuration["soapurl"]; //"https://soapserver/Service.svc";
Uri uri;
bool isValidURI = Uri.TryCreate(address, UriKind.RelativeOrAbsolute, out uri);
if (!isValidURI)
{
throw new Exception("URL is not valid");
}
EndpointAddressBuilder endpointAddressBuilder = new EndpointAddressBuilder();
endpointAddressBuilder.Uri = uri;
BasicHttpsBinding binding = new BasicHttpsBinding();
binding.Security.Mode = BasicHttpsSecurityMode.Transport;
binding.MaxReceivedMessageSize = 9000000;
binding.MaxBufferPoolSize = 9000000;
Service1Client SC = new Service1Client(binding, endpointAddressBuilder.ToEndpointAddress());
// Suppress cert error for now
SC.ClientCredentials.ServiceCertificate.SslCertificateAuthentication =
new X509ServiceCertificateAuthentication()
{
CertificateValidationMode = X509CertificateValidationMode.None,
RevocationMode = X509RevocationMode.NoCheck
};
return SC;
}
< /code>
Я пробовал явно установить протокол на TLS 1.2: < /p>
public Service1Client GetSoapClient()
{
string address = _configuration["soapurl"]; //"https://soapserver/Service.svc";
Uri uri;
bool isValidURI = Uri.TryCreate(address, UriKind.RelativeOrAbsolute, out uri);
if (!isValidURI)
{
throw new Exception("URL is not valid");
}
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
EndpointAddressBuilder endpointAddressBuilder = new EndpointAddressBuilder();
endpointAddressBuilder.Uri = uri;
// SC.Endpoint.Address = endpointAddressBuilder.ToEndpointAddress();
BasicHttpsBinding binding = new BasicHttpsBinding();
binding.Security.Mode = BasicHttpsSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.MaxReceivedMessageSize = 900000;
binding.MaxBufferPoolSize = 900000;
Service1Client SC = new Service1Client(binding, endpointAddressBuilder.ToEndpointAddress()) ;
SC.Endpoint.EndpointBehaviors.Add(new SslProtocolCertificateEndpointBehavior()
{
SslProtocols = SslProtocols.Tls12
});
SC.ClientCredentials.ServiceCertificate.SslCertificateAuthentication =
new X509ServiceCertificateAuthentication()
{
CertificateValidationMode = X509CertificateValidationMode.None,
RevocationMode = X509RevocationMode.NoCheck
};
return SC;
}
Любые мысли или идеи оценены.
Подробнее здесь: https://stackoverflow.com/questions/796 ... -use-tls-1