admin管理员组

文章数量:1129657

I have a problem, I am developing an application in .NET 8 based on an existing one in Visual Basic that used a web service of type SOAP. To be able to use this web service I pass it a certificate and use a BasicHttpsBinding with Security.Mode = BasicHttpsSecurityMode.Transport.

The problem I have is that when I call the web service it returns an error saying that the security header is missing and the message is not signed. The previous application had a line where I selected the Protection level to Sign but now in .NET 8 I can't access that property.

I leave you the code I have in case I am missing something, I have been doing this for many months and I can't find the solution.

SOAPService _cliente = new SOAPServicePortTypeClient(SOAPServicePortTypeClient.EndpointConfiguration.SOAPServicePort);

var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

_cliente.Endpoint.Binding = binding;

_cliente.ClientCredentials.ClientCertificate.Certificate = await _certificadoCnmvService.GetCertificado();
_cliente.ClientCredentials.ServiceCertificate.DefaultCertificate = ObtenerCertificadoX509_BD("Certificado");

_cliente.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode =
    X509CertificateValidationMode.None;
_cliente.ClientCredentials.ServiceCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck;
_cliente.Endpoint.EndpointBehaviors.Add(new CustomEndpointBehavior());

var request = createrequest(contrato);
var response = _cliente.WebService(request);

In the old app, I was using

_cliente.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign 

but now in .NET 8, this is impossible.

Any idea about how I can do this? I need send the request signed.

I did try all about the code.

本文标签: soapNET 8 set SystemNetSecurityProtectionLevelStack Overflow