Bienvenido a Facturas y Respuestas.

Esperamos que encuentre la respuesta a su pregunta. Y si no, puede formularla para que los expertos de la comunidad la respondan.

Preguntar

Este blog es creado y administrado por:

Copyright - 2020

0 votos
por en Generalidades

Hola, actualmente estoy haciendo una aplicacion que permita consultar si un CUFE es valida en la DIAN. Estoy usando el siguiente codigo :

const string apiUrl = "https://vpfe-hab.dian.gov.co/WcfDianCustomerServices.svc";

byte[] archivo; //= FileToByteArray(@"c:\temp\ws_f0890900161000000dab3.zip");

EndpointAddress endpointAddress = new EndpointAddress(new Uri(apiUrl));

var securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();

securityElement.AllowInsecureTransport = false;

securityElement.EnableUnsecuredResponse = true;

securityElement.IncludeTimestamp = false;

var encodingElement = new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8);

var transportElement = new HttpsTransportBindingElement();

var binding = new CustomBinding(securityElement, encodingElement, transportElement);

wsDian.WcfDianCustomerServicesClient Service = new WcfDianCustomerServicesClient(binding, endpointAddress);

Service.ClientCredentials.UserName.UserName = "MiSoftwareID";

Service.ClientCredentials.UserName.Password = "MiContraseñaEnSHA256";

Service.GetStatus(strCuf);

Pero estoy obteniendo el siguiente error :

Error al realizar la solicitud HTTP a https://vpfe-hab.dian.gov.co/WcfDianCustomerServices.svc. Esto puede deberse a que el certificado del servidor no está configurado correctamente en HTTP.SYS en el caso HTTPS. La causa puede ser también una falta de coincidencia del enlace de seguridad entre el cliente y el servidor.

Me pueden ayudar por favor

1 Respuesta

0 votos
por

Te hace falta agregar el certificado de cliente a la conexión.

Sería algo así:

var certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2 certificate( rutadelcertificadoPFX );

Service.ClientCredentials.ClientCertificate.Certificate = certificate;
...