【问题标题】:Does SAVON support client side certificates authenticationSAVON 是否支持客户端证书身份验证
【发布时间】:2013-04-05 02:16:01
【问题描述】:

我正在评估 savon 是否使用 Web 服务...但如果我可以使用 SSL 客户端证书对提供 SOAP Web 服务的服务器进行身份验证,我找不到任何信息。我阅读了文档,但没有找到任何相关信息。

有人知道 SAVON 是否支持客户端证书身份验证吗?

问候 假的

【问题讨论】:

    标签: ruby ssl-certificate savon


    【解决方案1】:

    Savon 的最新稳定版本(目前为 2.2.0)通过全局选项支持 SSL 客户端证书。请参考the documentation中的SSL部分。

    这是一些示例代码,假设 httpclient 与 httpi 一起使用:

    savonConfig = {
        :namespace => "http://...com",
        :endpoint => 'https://...:557/x/b/c',
        #:wsdl => 'https://...:557/x/b/c?wsdl',
        :log_level => :debug,
        :log => true,
        :ssl_verify_mode => :none,
        :ssl_cert_file => 'publicCert.pem',
        :ssl_cert_key_file => 'privateKey.pem',
        :ssl_cert_key_password => '1234',
        :open_timeout => 600,
        :read_timeout => 600
    }
    
    client = Savon.client savonConfig
    
    soapBody = {
    ...
    }
    
    
    calcResponse = client.call(:charge, :message => soapBody)
    

    如果您有 pfx 证书/密钥文件,则直接使用它可能会遇到问题 - 因此您可能希望将它们拆分为单独的文件 - 请参阅此页面以获取信息:Extract public/private key from PKCS12 file for later use in SSH-PK-Authentification

    希望对您有所帮助!
    丹尼尔

    【讨论】:

    • 非常感谢,应该意识到这些选项是针对客户端证书的(假设它们没有被提及为“客户端”)。我想你也需要使用 httpclient 才能工作......
    • Savon 版本 2 中的 HTTP 选项用于创建 HTTPI::Request。所以这取决于适配器是否支持。
    【解决方案2】:

    我们在尝试让 savon 客户端使用 ssl 客户端身份验证但同时绕过主机验证时遇到问题......

    https://github.com/savonrb/savon/issues/679

    client = Savon.client(log_level: :debug,
    log: true,
    ssl_verify_mode: :none,
    ssl_cert_file: (Rails.root + 'signed.cer').to_s,
    ssl_cert_key_file: ('private.key').to_s,
    wsdl: "https://example.com/Service?wsdl",
    endpoint: "https://example.com/Service")
    

    Like 失败 对 wir.dhswir.org (net_http) 的 HTTPI GET 请求 HTTPI::SSLError: SSL_read: ssl 握手失败

    没有萌信息..

    我们已经尝试过 savon 2.2.0、2.3.0 和 2.11.0。错误消息略有不同。

    我们使用相同的 PEM 格式的密钥和证书来 savon 并使用 unix WGET 进行比较。如果我们不通过 --no-check-certificate,WGET 将失败,但是如果我们添加它通过并且可以进行 ssl 客户端身份验证并获得访问权限

    wget 'https://example.com/CDC/VaccinationService?wsdl'  --certificate=example-int-wi-signed.cer --private-key=private.key -O- --no-check-certificate
    

    【讨论】:

      猜你喜欢
      • 2015-12-26
      • 1970-01-01
      • 2011-04-09
      • 2013-10-07
      • 1970-01-01
      • 2022-06-23
      • 1970-01-01
      • 2018-02-12
      • 2012-09-01
      相关资源
      最近更新 更多