【问题标题】:How can i implement keystore (certificate) soapui in C#?如何在 C# 中实现密钥库(证书)soapui?
【发布时间】:2019-04-13 00:21:26
【问题描述】:

我已经发送了一个请求,并从使用 SOAPUI 的 Web 服务获得了响应

为此,我将客户端证书添加到 SOAPUI -> 首选项 -> SSL 设置

它成功了。 (如果我不添加密钥库和密码,我会收到 ssl 握手错误)

我的问题是我无法在 C# 代码中实现这个(soapui 密钥库功能)。下面是我的代码和我得到的错误。

【问题讨论】:

  • 请不要将代码发布为图片。人们很难复制和粘贴您的代码以尝试运行它或发布答案。

标签: c# web-services soap certificate ssl-certificate


【解决方案1】:

您可以在端点事件中附加您的证书。

【讨论】:

  • 谢谢!我就是这样解决问题的
【解决方案2】:

我终于找到了问题所在。

您应该在创建 Web 服务实例时设置客户端证书。 顺便说一句,ClientCredentials.ServiceCertificate.SslCertificateAuthentication 选项仅用于忽略服务器证书是否有效。

        X509Certificate2 x509 = Utils.GetZBCertificate();
        ClientCredentials.ServiceCertificate.SslCertificateAuthentication = new System.ServiceModel.Security.X509ServiceCertificateAuthentication();
        ClientCredentials.ServiceCertificate.SslCertificateAuthentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
        ChannelFactory.Credentials.ClientCertificate.Certificate = x509;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 2011-01-04
    • 2012-07-16
    相关资源
    最近更新 更多