简体   繁体   English

访问安全的Web服务

[英]Accessing Securised Web Service

I need to connect to a provider's web service with a Windows Form application. 我需要使用Windows Form应用程序连接到提供商的Web服务。 He gives me a certificate to access it but I have a security problem. 他给了我一个访问它的证书,但是我遇到了安全问题。

I have done these following steps : 我已完成以下步骤:

  1. Add certificate to personal store (on IE & Firefox) 将证书添加到个人商店(在IE和Firefox上)
  2. Generate a proxy with the remote wsdl (no problem) 使用远程wsdl生成代理(没问题)
  3. Use this code to call a method : 使用此代码来调用方法:

    `using (service1.MessagesService m = new service1.MessagesService()) { 使用(service1.MessagesService m =新service1.MessagesService()){

    X509Certificate crt = new X509Certificate(@"C:\\OpenSSL\\bin\\thecert.p12",string.Empty); X509Certificate crt =新的X509Certificate(@“ C:\\ OpenSSL \\ bin \\ thecert.p12”,string.Empty);
    m.ClientCertificates.Add(crt); m.ClientCertificates.Add(crt);
    var result = m.AuthoriseTransaction(aut); var result = m.AuthoriseTransaction(aut);

    this.textBox1.AppendText(result.id.ToString()); 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. 基础连接已关闭:无法建立通道SSL / TLS的信任关系。

Thanks for your help 谢谢你的帮助

Your connection isn't being authorised correctly, is the webservice over https? 您的连接未正确授权,Web服务是否通过https? You may need to create a custom implementation of CertificatePolicy . 您可能需要创建一个CertificatePolicy的自定义实现。 See this article for an example. 请参阅本文的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM