[Feature #2579] Net::HTTP.start("www.ruby-lang.org", use_ssl: true) $B$G(B SSL $BMxMQ$r2DG=$K(B

Feature #2579: Net::HTTP.start(“www.ruby-lang.org”, use_ssl: true)
e$B$Ge(B SSL e$BMxMQ$r2DG=$Ke(B
http://redmine.ruby-lang.org/issues/show/2579

e$B5/I<<Te(B: Yui NARUSE
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal

e$B=>Mh!“e(BNet::HTTP e$B$Ge(B https e$B%”%/%;%9$r$9$k$?$a$K$Oe(B

http = Net::HTTP.new(“www.ruby-lang.org”, 443) # port e$B$r;XDje(B
http.use_ssl = true # use_ssl e$B$re(B true e$B$Ke(B
http.verify_mode = OpenSSL::SSL::VERIFY_PEER #
e$B%G%U%)%k%H$@$H8!>Z$7$F$/$l$J$$$N$GJQ99e(B
http.start{|h| } # e$B$d$C$HK\Bje(B
http.finish # e$BGK4~e(B

e$B$J$I$H$9$kI,MW$,$"$j$^$7$?!#e(B

e$B$3$NDs0F$G$O!“e(BNet::HTTP(addr, opt){…}
e$B$H$$$&8F$S=P$7J}$rDI2C$7$^$9!#e(B
opt e$B$O%O%C%7%e$G!”%“%/%;%5$N$”$k9`L$r@_Dj$9$k;v$,=PMh$^$9!#e(B

e$B$J$!“@^3Q$N?7e(B API e$B$J$N$G!”$3$Ne(B API
e$B$r;H$C$?>l9g!“e(Bverify_mode e$B$N%G%U%)%k%H$,e(B VERIFY_PEER
e$B$K$J$C$F$$$^$9!#e(B
e$B$D$^$j!”$3$Ne(B API e$B$rMQ$$$?>l9g%G%U%)%k%H$Ge(B SSL
e$B=pL>$NM-8z@-$r8!::$9$k$?$a!"e(B
e$B4|8B@Z$l$d%
%l%*%l>ZL@=q$N>l9gNc30$,=P$^$9!#e(B

e$B$3$l$K$h$j!"$5$C$-$N$O0J2<$N$h$&$K=q$1$^$9!#e(B
Net::HTTP.start(“www.ruby-lang.org”, use_ssl: true){|h| }

P.S.
e$B$J$*!"0J>e$NNc$GMQ$$$F$$$ke(B www.ruby-lang.org e$B$O!"8=:_e(B SSL
e$B>ZL@=q$,4|8B@Z$l$N$?$a!"e(B
e$B$3$NNc$r:#<B9T$9$k$H8!>Z$K<:GT$7$FNc30$,=P$^$9!#e(B
e$B:#$Oe(B StartCom e$B$H$+$@$HL5NA$Ge(B
e$B<gMW4D6-$G%k!<%H>ZL@=q$,F~$C$F$$$ke(B Web e$B%5!<%PMQ$Ne(B SSL
e$B>ZL@=q$,<hF@$G$-$^$9$+$i!"e(B
e$B$=$&$$$&$N$KF~$lBX$($?J}$,$$$$$N$G$O$J$$$G$7$g$&$+!#e(B

e$B$J$+$@$G$9!#e(B

At Sat, 9 Jan 2010 20:34:23 +0900,
Yui NARUSE wrote in [ruby-dev:40003]:

e$B$3$NDs0F$G$O!“e(BNet::HTTP(addr, opt){…} e$B$H$$$&8F$S=P$7J}$rDI2C$7$^$9!#e(B
opt e$B$O%O%C%7%e$G!”%“%/%;%5$N$”$k9`L$r@_Dj$9$k;v$,=PMh$^$9!#e(B

e$B$J$!“@^3Q$N?7e(B API e$B$J$N$G!”$3$Ne(B API e$B$r;H$C$?>l9g!“e(Bverify_mode e$B$N%G%U%)%k%H$,e(B VERIFY_PEER e$B$K$J$C$F$$$^$9!#e(B
e$B$D$^$j!”$3$Ne(B API e$B$rMQ$$$?>l9g%G%U%)%k%H$Ge(B SSL e$B=pL>$NM-8z@-$r8!::$9$k$?$a!"e(B
e$B4|8B@Z$l$d%
%l%*%l>ZL@=q$N>l9gNc30$,=P$^$9!#e(B

verify_modee$B$N;XDj$,LLE]$J$N$G!"$3$&$7$F$O$I$&$G$7$g$&$+!#e(B

e$B$3$l$K$h$j!"$5$C$-$N$O0J2<$N$h$&$K=q$1$^$9!#e(B
Net::HTTP.start(“www.ruby-lang.org”, use_ssl: true){|h| }

Net::HTTP.start(“www.ruby-lang.org”, use_ssl: true, verify_mode:
“none”){|h| }

Index: lib/net/http.rb

— lib/net/http.rb (revision 26256)
+++ lib/net/http.rb (working copy)
@@ -451,6 +451,23 @@ module Net #:nodoc:
# return value of this method is the newly created Net::HTTP object
# itself, and the caller is responsible for closing it upon
completion.

  • def HTTP.start(address, port = nil, p_addr = nil, p_port = nil,
    p_user = nil, p_pass = nil, &block) # :yield: +http+
  •  new(address, port, p_addr, p_port, p_user, p_pass).start(&block)
    
  • def HTTP.start(address, *arg, &block) # :yield: +http+
  •  arg.pop if opt = Hash.try_convert(arg.last)
    
  •  port, p_addr, p_port, p_user, p_pass = *arg
    
  •  port = https_default_port if opt[:use_ssl] && !port
    
  •  http = new(address, port, p_addr, p_port, p_user, p_pass)
    
  •  case verify_mode = opt[:verify_mode]
    
  •  when Symbol, String
    
  •    opt = opt.merge(verify_mode: 
    

OpenSSL::SSL.const_get(“VERIFY_#{verify_mode.to_s.upcase}”))

  •  when nil
    
  •    opt = opt.merge(verify_mode: OpenSSL::SSL::VERIFY_PEER)
    
  •  end
    
  •  http.methods.grep(/\A(\w+)=\z/) do |meth|
    
  •    key = $1.to_sym
    
  •    opt.key?(key) or next
    
  •    http.__send__(meth, opt[key])
    
  •  end
    
  •  http.start(&block)
    
    end

e$B%A%1%C%He(B #2579 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

SSL
e$B>ZL@=q$N8!>Z$r$7$J$$$H$$$&%$%^%$%A%*%9%9%a$G$-$J$$5sF0$r0UL#$9$k!"e(B
OpenSSL::SSL::VERIFY_NONE
e$B$N;XDj$r$o$6$o$63Z$K$9$kI,MW$O$J$$$H;W$$$^$9!#e(B

http://redmine.ruby-lang.org/issues/show/2579

e$B$J$+$@$G$9!#e(B

At Sun, 10 Jan 2010 07:34:48 +0900,
Yui NARUSE wrote in [ruby-dev:40012]:

SSL e$B>ZL@=q$N8!>Z$r$7$J$$$H$$$&%$%^%$%A%*%9%9%a$G$-$J$$5sF0$r0UL#$9$k!"e(B
OpenSSL::SSL::VERIFY_NONE e$B$N;XDj$r$o$6$o$63Z$K$9$kI,MW$O$J$$$H;W$$$^$9!#e(B

e$B$J$k$[$I!#e(BVERIFY_FAIL_IF_NO_PEER_CERTe$B$H$+$O$I$&$J$s$@$m$&!"$H;We(B
e$B$$$^$7$?$,$R$g$C$H$7$F$3$N$X$s$O%S%C%H%U%i%0$G$9$+!#e(B

e$B%A%1%C%He(B #2579 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

e$B%S%C%H%U%i%0$G$9$M!#e(B
e$B$G!“e(BVERIFY_FAIL_IF_NO_PEER_CERT
e$B$G$9$,$3$l$O%5!<%P!<MQ$N%U%i%0$J$N$G!“e(B
e$B%/%i%$%”%s%HMQ%i%$%V%i%j$G$”$ke(B net/http
e$B$G$O;H$o$l$J$$$O$:$G$9!#e(B

http://redmine.ruby-lang.org/issues/show/2579

e$B%A%1%C%He(B #2579 e$B$,99?7$5$l$^$7$?!#e(B (by Yui NARUSE)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

This issue was solved with changeset r26297.
Yui, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


http://redmine.ruby-lang.org/issues/show/2579