[#44289] [Ruby 1.9 - Feature #5128][Open] 日本語ドキュメントをUTF-8に — Shyouhei Urabe <shyouhei@...>

34 messages 2011/08/01
[#44293] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Nobuyoshi Nakada <nobu@...> 2011/08/01

[#44295] Re: [ruby-dev:44293] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Urabe Shyouhei <shyouhei@...> 2011/08/01

(08/01/2011 11:52 AM), Nobuyoshi Nakada wrote:

[#44299] Re: [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Nobuyoshi Nakada <nobu@...> 2011/08/01

なかだです。

[#44418] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Ayumu AIZAWA <ayumu.aizawa@...> 2011/08/24

[#44431] Re: [ruby-dev:44418] [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — KOSAKI Motohiro <kosaki.motohiro@...> 2011/08/27

> あいざわです

[#44443] Re: [Ruby 1.9 - Feature #5128] 日本語ドキュメントをUTF-8に — Ayumu Aizawa <ayumu.aizawa@...> 2011/09/01

あいざわです

[#44315] [Ruby 1.9 - Bug #5139][Open] sigsegv のスタックオーバフロー — Tomoyuki Chikanaga <nagachika00@...>

18 messages 2011/08/02

[#44329] [Ruby 1.9 - Bug #5151][Open] test/socket/test_socket.rb fail when udp connection failed — Ayumu AIZAWA <ayumu.aizawa@...>

16 messages 2011/08/02

[#44368] [Ruby 1.9 - Feature #5180][Open] net/http の接続時に用いる IP アドレスの指定 — Yui NARUSE <naruse@...>

15 messages 2011/08/10

[#44413] [Ruby 1.9 - Bug #5217][Open] lineno is broken when source code has about 7000 lines — Yusuke Endoh <mame@...>

11 messages 2011/08/23

[ruby-dev:44377] Re: [Ruby 1.9 - Feature #5180] net/http の接続時に用いる IP アドレスの指定

From: tadanori kojima <[email protected]>
Date: 2011-08-11 03:19:40 UTC
List: ruby-dev #44377
On Wed, 10 Aug 2011 18:33:08 +0900
"NARUSE, Yui" <[email protected]> wrote:

> 2011年8月10日18:21 tadanori kojima <[email protected]>:
> >
> > load balancer利用時のreal IPへの接続などのユースケースは理解できますが
> > -----
> > Net::HTTP.start("127.0.0.1") {|h|
> >  print h.request_get( '/index.html' , {"host"=>"ruby-lang.org"}).body
> > }
> >
> > ※startはIP指定、リクエスト時のhostヘッダにホスト名
> > -----
> >
> > というのがHTTP的なふつうの対処な気がします
> 
> 基本的な HTTP に対する理屈としては同意するところなんですが、
> https だと connection 張る時点でホスト名が必要なため、それだとまずいんです。


意味がわかりました

でもsslってcommon nameの検証までやってたっけ?
と、net/http.rbのソースをみるとconnect内に

−・−・−・−・−・−
  s.connect
  if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
     s.post_connection_check(@address)
   end
−・−・−・−・−・−

とあるので、1.8.5だと(手元のマシンがcent5なので。。。)
−・−・−・−・−・−
 diff -u net/http.rb.orig net/http.rb
--- net/http.rb.orig    2011-08-11 11:09:21.000000000 +0900
+++ net/http.rb 2011-08-11 11:39:08.000000000 +0900
@@ -470,6 +470,7 @@
       @debug_output = nil
       @use_ssl = false
       @ssl_context = nil
+      @common_name = nil
     end
 
     def inspect
@@ -526,6 +527,8 @@
       false   # redefined in net/https
     end
 
+    attr_accessor :common_name
+
     # Opens TCP connection and HTTP session.
     # 
     # When this method is called with block, gives a HTTP object
@@ -585,7 +588,7 @@
         end
         s.connect
         if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
-          s.post_connection_check(@address)
+          s.post_connection_check( @common_name || @address)
         end
       end
       on_connect

−・−・−・−・−・−
で、
−・−・−・−・−・−
require 'net/http'
addrs = %w/192.168.0.1 192.168.0.2 192.168.0.3/
addrs.each do |addr|
  Net::HTTP.start(addr, use_ssl: true, common_name: 'example.org'){|h| p h.get('/')}
end
−・−・−・−・−・−
とcommon nameを指定するほうが好みです:-)



おおもとの問題は
 接続サーバの指定(IP/Hostname)、
 HTTPのHostヘッダ(IP/Hostname、VirtualHostなどで利用)
 SSLのCN検証(IP/Hostnameとは別にCNAMEもあり得る)
と、レイヤを意識したパケットの組み立て方が必要なことでしょうか
すっきりした解決方法は浮かばないですね。。。




> > ホストがv4/v6の両アドレスを持つ場合などにv4で接続したい、
> > となるときも同じような感じでしょうか
> 
> そうですね。
> 
> -- 
> NARUSE, Yui  <[email protected]>

--
End of mail


In This Thread