mardi 4 juillet 2017

call java Https webservice in .net with certificate authentication

I have a Java webservice which is configured as https with certificate. I am able to browse wsdl in browser. When i access the webservice in C# it throws an error.

I have installed the certificate in trusted root certificates.

Below is the code.

Creating binding

WSHttpBinding myBinding = new WSHttpBinding();
myBinding.Security.Mode = SecurityMode.Transport;
myBinding.Security.Transport.ClientCredentialType = 
HttpClientCredentialType.Certificate;

EndpointAddress ea = new EndpointAddress("https://localhost:8443/WSRemoteServices/UtilityInformationProvider");
UtilityInformationProviderClient cc = new UtilityInformationProviderClient(myBinding, ea);

cc.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.Root, X509FindType.FindBySubjectName,"localhost");

 string version = cc.getTeisVersion(null);

Below is the error we are getting.

"<b>Could not establish trust relationship for the SSL/TLS secure channel with authority."</b>




Aucun commentaire:

Enregistrer un commentaire