.NET 8 C# SOAP -Client funktioniert nicht nach dem Upgrade von SOAP -Server, um TLS 1.2 zu verwendenC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 .NET 8 C# SOAP -Client funktioniert nicht nach dem Upgrade von SOAP -Server, um TLS 1.2 zu verwenden

Post by Anonymous »

Ich habe eine SOAP-Client-Anwendung, die einen Fehler auswirft, der möglicherweise aufgrund des SOAP-Servers TLS 1.2 verwendet hat. ' redigiert < /strong> < /em>' ist falsch oder weil die Nachricht einen ungültigen oder abgelaufenen Sicherheitskontext -Token enthält oder weil es ein Missverhältnis zwischen den Bindungen gibt. Bindung.

Code: Select all

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>
Ich habe versucht, das Protokoll explizit auf TLS 1.2: < /p>
festzulegenpublic 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;
}
Ich erhalte jedoch immer noch den gleichen Fehler.
Alle Gedanken oder Ideen geschätzt.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post