From a3bfedac36e946790c966c0319765479df770e4b Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Mon, 24 Dec 2007 07:31:23 +0000 Subject: * sample/openssl: reviewed and remove dependency on getopts.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/openssl/wget.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sample/openssl/wget.rb') diff --git a/sample/openssl/wget.rb b/sample/openssl/wget.rb index 0362ab980d..ee637204db 100644 --- a/sample/openssl/wget.rb +++ b/sample/openssl/wget.rb @@ -1,11 +1,11 @@ #!/usr/bin/env ruby require 'net/https' -require 'getopts' +require 'optparse' -getopts nil, 'C:' +options = ARGV.getopts('C:') -ca_path = $OPT_C +cert_store = options["C"] uri = URI.parse(ARGV[0]) if proxy = ENV['HTTP_PROXY'] @@ -18,11 +18,12 @@ h = Net::HTTP.new(uri.host, uri.port, prx_host, prx_port) h.set_debug_output($stderr) if $DEBUG if uri.scheme == "https" h.use_ssl = true - if ca_path - h.verify_mode = OpenSSL::SSL::VERIFY_PEER - h.ca_path = ca_path - else - $stderr.puts "!!! WARNING: PEER CERTIFICATE WON'T BE VERIFIED !!!" + if cert_store + if File.directory?(cert_store) + h.ca_path = cert_store + else + h.ca_file = cert_store + end end end -- cgit v1.2.3