且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SAVON 是否支持客户端证书认证

更新时间:2021-09-16 21:54:31

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

the latest stable version of Savon (2.2.0 at this moment) supports SSL client certificates via global options. Please refer to the SSL section in the documentation.

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

Here is some example code, assuming httpclient is used with 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 证书/密钥文件,则直接使用它可能会遇到问题-因此您可能希望将它们拆分为单独的文件-有关信息,请参阅此页面:从 PKCS12 文件中提取公钥/私钥以备后用在 SSH-PK-身份验证中

If you have a pfx certificate/key file, you may have problems using it directly - so you might want to split them out into separate files - see this page for info: Extract public/private key from PKCS12 file for later use in SSH-PK-Authentification

希望有帮助!
丹尼尔

Hope that helps!
Daniel