mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d8e22fa1dd
commit
a6e805f75e
3 changed files with 23 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
Sat May 7 22:22:37 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* test/webrick/test_ssl_server.rb: Added basic test for `webrick/ssl`
|
||||
|
|
|
@ -108,7 +108,8 @@ module WEBrick
|
|||
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
|
||||
|
|
|
@ -25,4 +25,18 @@ class TestWEBrickSSLServer < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue