ruby-changes:42867
From: hsbt <ko1@a...>
Date: Sat, 7 May 2016 21:40:43 +0900 (JST)
Subject: [ruby-changes:42867] hsbt:r54941 (trunk): * lib/webrick/ssl.rb: Accept string value for SSLCertName. It is used
hsbt 2016-05-07 22:37:18 +0900 (Sat, 07 May 2016) New Revision: 54941 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54941 Log: * lib/webrick/ssl.rb: Accept string value for SSLCertName. It is used to invoke ssl server with command line. [fix GH-1329] Patch by @kerlin * test/webrick/test_ssl_server.rb: Added test for GH-1329 Modified files: trunk/ChangeLog trunk/lib/webrick/ssl.rb trunk/test/webrick/test_ssl_server.rb Index: test/webrick/test_ssl_server.rb =================================================================== --- test/webrick/test_ssl_server.rb (revision 54940) +++ test/webrick/test_ssl_server.rb (revision 54941) @@ -25,4 +25,18 @@ class TestWEBrickSSLServer < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/webrick/test_ssl_server.rb#L25 sock.close } end + + def test_self_signed_cert_server_with_string + config = { + :SSLEnable => true, + :SSLCertName => "/C=JP/O=www.ruby-lang.org/CN=Ruby" + } + TestWEBrick.start_server(Echo, config){|server, addr, port, log| + sock = OpenSSL::SSL::SSLSocket.new(TCPSocket.new(addr, port)) + sock.connect + sock.puts(server.ssl_context.cert.subject.to_s) + assert_equal("/C=JP/O=www.ruby-lang.org/CN=Ruby\n", sock.gets, log.call) + sock.close + } + end end Index: ChangeLog =================================================================== --- ChangeLog (revision 54940) +++ ChangeLog (revision 54941) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat May 7 22:22:37 2016 SHIBATA Hiroshi <hsbt@r...> + + * lib/webrick/ssl.rb: Accept string value for SSLCertName. It is used + to invoke ssl server with command line. + [fix GH-1329] Patch by @kerlin + * test/webrick/test_ssl_server.rb: Added test for GH-1329 + Sat May 7 21:55:12 2016 SHIBATA Hiroshi <hsbt@r...> * test/webrick/test_ssl_server.rb: Added basic test for `webrick/ssl` Index: lib/webrick/ssl.rb =================================================================== --- lib/webrick/ssl.rb (revision 54940) +++ lib/webrick/ssl.rb (revision 54941) @@ -108,7 +108,8 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/ssl.rb#L108 cert = OpenSSL::X509::Certificate.new cert.version = 2 cert.serial = 1 - name = OpenSSL::X509::Name.new(cn) + name = (cn.kind_of? String) ? OpenSSL::X509::Name.parse(cn) + : OpenSSL::X509::Name.new(cn) cert.subject = name cert.issuer = name cert.not_before = Time.now -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/