开发者

Accessing Securised Web Service

开发者 https://www.devze.com 2022-12-28 22:12 出处:网络
I need to connect to a provider\'s web service with a Windows Form application. He gives me a certificate to access it but I have a security problem.

I need to connect to a provider's web service with a Windows Form application. He gives me a certificate to access it but I have a security problem.

I have done these following steps : 开发者_StackOverflow中文版

  1. Add certificate to personal store (on IE & Firefox)
  2. Generate a proxy with the remote wsdl (no problem)
  3. Use this code to call a method :

    `using (service1.MessagesService m = new service1.MessagesService()) {

    X509Certificate crt = new X509Certificate(@"C:\OpenSSL\bin\thecert.p12",string.Empty);

    m.ClientCertificates.Add(crt);

    var result = m.AuthoriseTransaction(aut);

    this.textBox1.AppendText(result.id.ToString());

    }`

I have the following error :

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

Thanks for your help


Your connection isn't being authorised correctly, is the webservice over https? You may need to create a custom implementation of CertificatePolicy. See this article for an example.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号