0

How to call a webservice (created in java) with ws security, they provided a certificate file , username & password, i tried using Web Services Enhancements (WSE) 3.0, Inherited the service proxy from Microsoft.Web.Services3.WebServicesClientProtocol used username password tocken

  UsernameToken tocken = new UsernameToken("uname", "pwd");
  Service.RequestSoapContext.Security.Tokens.Add(tocken);

got error "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

Is it because of the client certificate ? I aslo tried

 X509Certificate xCert = new X509Certificate();
  xCert = X509Certificate.CreateFromCertFile("certificate_path.cer");
  Service.ClientCertificates.Add(xCert);
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
Priyan R
  • 1,042
  • 1
  • 15
  • 24
  • WSE is old thing WCF is technology that replaces it – Denis Palnitsky Jan 26 '10 at 08:24
  • It's not clear from the question, what aspect of ws-security is used. As far as I can see, your client expects the service to use HTTPS and not message-level encryption/signing. If that's your case, try adding the certificate to 'trusted people' cert storage. And yes, use WCF ) – Dmitry Ornatsky Jan 26 '10 at 09:00

1 Answers1

0

I solved the issue its becuase of ssl certificate validation problem, used

 UsernameToken token = new UsernameToken("uname", "pwd", PasswordOption.SendPlainText);
 Service.RequestSoapContext.Security.Tokens.Add(token);
 System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();           


    public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
            {
                public TrustAllCertificatePolicy()
                { }

                public bool CheckValidationResult(ServicePoint sp,
                 X509Certificate cert, WebRequest req, int problem)
                {

                    return true;
                }
            }
Priyan R
  • 1,042
  • 1
  • 15
  • 24