连接:SSL_connect返回= 1 errno = 0状态= SSLv3读取服务器证书B:证书验证失败(OpenSSL :: SSL :: SSLError)
我很难受SSL验证证书的时间.我对证书的工作方式一无所知,因此这是一个主要的障碍.这是运行脚本时出现的错误:
I'm having a terrible time getting SSL to verify a certificate. I'm completely ignorant on how certificates work so that's a major handicap to begin with. Here's the error I get when running the script:
c:/Ruby191/lib/ruby/1.9.1/net/http.rb:611:in `connect': SSL_connect returned=1 e
rrno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL
::SSL::SSLError)
以下是相关代码:
client = Savon::Client.new order_svc
request = client.create_empty_cart { |soap, http|
http.auth.ssl.cert_file = 'mycert.crt'
http.auth.ssl.verify_mode = :none
http.read_timeout = 90
http.open_timeout = 90
http.headers = { "Content-Length" => "0", "Connection" => "Keep-Alive" }
soap.namespaces["xmlns:open"] = "http://schemas.datacontract.org/2004/07/Namespace"
soap.body = {
"wsdl:brand" => brand,
"wsdl:parnter" => [
{"open:catalogName" => catalogName, "open:partnerId" => partnerId }
] }.to_soap_xml
}
感谢您的帮助.
注意:我在较低级别的环境中使用测试自动化 没有正确签名的证书,并且经常会抛出 由于域签名不匹配而导致的错误.对于在的问题 手,绕过签名是一个可行的解决方案,但这不是一个可行的解决方案 用于生产水平开发的解决方案.
Note: I was working with test automation in lower level environments that did not have properly signed certificates and would often throw errors due to domain signatures not matching. For the problem at hand, bypassing signatures was a plausible solution but it is not a solution to be used for production level development.
我的问题是我正在尝试验证自签名证书.我要做的就是放下以下代码,并忽略与验证证书有关的任何事情.
My problem is that I am trying to validate a self-signed certificate. All I had to do was put the following code and omit anything to do with validating certificates.
对于遇到同样问题的SOAP和REST调用,我都必须这样做.
I had to do this for both my SOAP and REST calls that were both experiencing the same issue.
使用Savon的SOAP
client = Savon::Client.new order_svc
request = client.create_empty_cart { |soap, http|
http.auth.ssl.verify_mode = :none
http.headers = { "Content-Length" => "0", "Connection" => "Keep-Alive" }
soap.namespaces["xmlns:open"] = "http://schemas.datacontract.org/2004/07/Namespace"
soap.body = {
"wsdl:brand" => brand,
"wsdl:parnter" => [
{"open:catalogName" => catalogName, "open:partnerId" => partnerId }
] }.to_soap_xml
}
使用HTTPClient的REST
client = HTTPClient.new
client.ssl_config.verify_mode=(OpenSSL::SSL::VERIFY_NONE)
resp = client.get(Methods)