ホーム > ブログ > Ruby 「warning: peer certificate won’t be verified in this SSL session」

Ruby 「warning: peer certificate won’t be verified in this SSL session」

Net::HTTPライブラリを使用してSSL下のWEBページを取得した際に、
以下のような警告文がでます。

warning: peer certificate won't be verified in this SSL session

これを停めるには、
Net::HTTPのインスタンスメソッドverify_modeに下記の定数を指定します。

サンプルコード:
require 'net/https'
https = Net::HTTP.new("secure.example.com", 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
https.start { |w|
  response = w.get('/')
  puts response.body
}

※この場合、https.use_ssl = trueの指定は必須です。

参考サイト


環境
Ruby 1.8.7
CentOS 5.3
前の記事 «
次の記事 »