diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-19 08:28:33 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-19 08:28:33 +0000 |
commit | 049c3927ff0692282187507e3d4914bb8112ff0a (patch) | |
tree | e309494f4ffa535b8868d251db6bb26c399d1722 /test/openssl/test_ssl.rb | |
parent | 80f52f38c7751854a1ab7c3187d104f4c09d35e6 (diff) |
* ext/openssl/ossl_x509store.c
(ossl_x509store_set_time): add OpenSSL::X509::Store#time=.
(ossl_x509stctx_set_time): add OpenSSL::X509::StoreContext#time=.
* test/openssl/ossl_x509store.rb: test certificate validity times.
* ext/openssl/ossl_x509name.c (ossl_x509name_to_s): add optional
second argument to specify the output format (see also
X509_NAME_print_ex).
* ext/openssl/ossl_x509name.c (ossl_x509name_init): new constants:
OpenSSL::X509::Name::COMPAT, OpenSSL::X509::Name::RFC2253,
OpenSSL::X509::ONELINE, OpenSSL::X509::MULTILINE.
* ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name::RFC2253DN):
new module to provide the parse for RFC2253 DN format.
* ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name.parse_rfc2253):
new method to parse RFC2253 DN format.
* test/openssl/ossl_x509name.rb: add tests about RFC2253 DN.
* text/openssl/ssl_server.rb: try to listen ports from 20443 to 20542
while EADDRINUSE is raised.
* all changes in this entry are backport from 1.9.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl/test_ssl.rb')
-rw-r--r-- | test/openssl/test_ssl.rb | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index 5ca981798c..699563691e 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -54,23 +54,27 @@ class OpenSSL::TestSSL < Test::Unit::TestCase OpenSSL::TestUtils.issue_crl(*arg) end - def start_server(port, verify_mode, start_immediately, &block) + def start_server(port0, verify_mode, start_immediately, &block) server = nil begin cmd = [RUBY] cmd << "-d" if $DEBUG - cmd << SSL_SERVER << port.to_s << verify_mode.to_s + cmd << SSL_SERVER << port0.to_s << verify_mode.to_s cmd << (start_immediately ? "yes" : "no") server = IO.popen(cmd.join(" "), "w+") server.write(@ca_cert.to_pem) server.write(@svr_cert.to_pem) server.write(@svr_key.to_pem) pid = Integer(server.gets) - $stderr.printf("%s started: pid=%d\n", SSL_SERVER, pid) if $DEBUG - block.call(server) + if port = server.gets + if $DEBUG + $stderr.printf("%s started: pid=%d port=%d\n", SSL_SERVER, pid, port) + end + block.call(server, port.to_i) + end ensure if server - Process.kill(:KILL, pid) if pid > 0 + Process.kill(:KILL, pid) server.close end end @@ -86,15 +90,15 @@ class OpenSSL::TestSSL < Test::Unit::TestCase end def test_connect_and_close - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){ - sock = TCPSocket.new("127.0.0.1", PORT) + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|s, p| + sock = TCPSocket.new("127.0.0.1", p) ssl = OpenSSL::SSL::SSLSocket.new(sock) assert(ssl.connect) ssl.close assert(!sock.closed?) sock.close - sock = TCPSocket.new("127.0.0.1", PORT) + sock = TCPSocket.new("127.0.0.1", p) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true # !! assert(ssl.connect) @@ -104,8 +108,8 @@ class OpenSSL::TestSSL < Test::Unit::TestCase end def test_read_and_write - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){ - sock = TCPSocket.new("127.0.0.1", PORT) + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|s, p| + sock = TCPSocket.new("127.0.0.1", p) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true ssl.connect @@ -148,8 +152,8 @@ class OpenSSL::TestSSL < Test::Unit::TestCase end def test_starttls - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false){|s| - sock = TCPSocket.new("127.0.0.1", PORT) + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, false){|s, p| + sock = TCPSocket.new("127.0.0.1", p) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.sync_close = true str = "x" * 1000 + "\n" @@ -171,10 +175,10 @@ class OpenSSL::TestSSL < Test::Unit::TestCase end def test_parallel - start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){ + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|s, p| ssls = [] 10.times{ - sock = TCPSocket.new("127.0.0.1", PORT) + sock = TCPSocket.new("127.0.0.1", p) ssl = OpenSSL::SSL::SSLSocket.new(sock) ssl.connect ssl.sync_close = true |