Actions
Feature #13729
closedPATCH: Add Server Name Indication (SNI) support to WEBrick
    Feature #13729:
    PATCH: Add Server Name Indication (SNI) support to WEBrick
  
Description
WEBrick に Server Name Indication (SNI) サポートを追加するパッチです。
よくWEBrickで簡易サーバを立てているのですが、SNIでバーチャルホストを立てたかった(けどできなかった)のでパッチを書きました。
WEBrick::HTTPServer が元々持っているバーチャルホストの仕組みに乗っかっています。
一応テストも入っています。
Google Chrome + Let's Encryptの証明書(SANではない単一CNの証明書複数)でちゃんと接続できることも確認しました。
usage:
# master (default) server
master = WEBrick::HTTPSerevr.new({
    :ServerName => "master.example.com",
    :Port => 443,
    :SSLEnable => true,
    :SSLCertificate => "CN=master.example.com の証明書",
    :SSLPrivateKey => "秘密鍵",
})
master.mount_proc("/") { |req, res| res.body = "default host!\n" }
# virtual host
vhost = WEBrick::HTTPServer.new({
    :ServerName => "vhost.example.jp", # SNIバーチャルホスト名
    :Port => 443,                      # master serverと同じポート番号を指定
    :DoNotListen => true,              # true必須
    :SSLEnable => true,                # true必須
    :SSLCertificate => "CN=vhost.example.jp の証明書",
    :SSLPrivateKey => "秘密鍵",
})
vhost.mount_proc("/") { |req, res| res.body = "virtual host!\n" }
master.virtual_host(vhost)
master.start
Files
Actions
        
        
     Updated by Anonymous
          Updated by Anonymous