是否遵循以下链接:http://www.rubyinside.com/how-to-cure-nethttps-risky-default-https-behavior-4010.html
尝试执行以下代码段:
require 'always_verify_ssl_certificates'
AlwaysVerifySSLCertificates.ca_file = "C:/certs/cacert.pem"
puts "test 1"
http= Net::HTTP.new('https://some.ssl.site', 443)
http.use_ssl = true
req = Net::HTTP::Get.new('/')
response = http.request(req)
我收到以下错误:
api_basics.rb:4:in `<main>': uninitialized constant AlwaysVerifySSLCertificates (NameError)
已经安装了always_verify_ssl_certificates gem。
gem install always_verify_ssl_certificates
Fetching: always_verify_ssl_certificates-0.3.0.gem (100%)
Successfully installed always_verify_ssl_certificates-0.3.0
Parsing documentation for always_verify_ssl_certificates-0.3.0
Installing ri documentation for always_verify_ssl_certificates-0.3.0
Done installing documentation for always_verify_ssl_certificates after 0 seconds
1 gem installed
所以不确定出了什么问题。
答案 0 :(得分:1)
确实,always_verify_ssl_certificates gem没有定义这样的常量。 尝试重写如下:
require 'always_verify_ssl_certificates'
...
http= Net::HTTP.new('https://some.ssl.site', 443)
http.ca_file = "C:/certs/cacert.pem"
...