summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--MANIFEST2
-rw-r--r--ext/openssl/lib/openssl/buffering.rb11
-rw-r--r--ext/openssl/lib/openssl/ssl.rb9
-rw-r--r--ext/openssl/ossl_ssl.c14
-rw-r--r--test/openssl/test_ssl.rb2
-rw-r--r--test/openssl/test_x509name.rb30
-rw-r--r--test/openssl/test_x509store.rb3
-rw-r--r--test/openssl/utils.rb2
9 files changed, 68 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index f9b317e600..687237f3c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Thu Jul 1 03:16:09 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_ssl.c (ossl_ssl_read): take optional second argument
+ to specify a string to be written.
+
+ * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#read):
+ take optional second argument to specify a string to be written.
+
+ * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#gets):
+ refine regexp for end-of-line.
+
+ * ext/opnessl/lib/openssl/ssl.rb
+ (OpenSSL::SSL::SocketForwarder#listen): fix typo.
+
Wed Jun 30 11:38:51 2004 Elven <elven@elven.de>
* parse.y (primary): should not be NULL. [ruby-core:03098]
diff --git a/MANIFEST b/MANIFEST
index c4fc648bd3..f63f3b71b7 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -776,6 +776,8 @@ test/fileutils/test_nowrite.rb
test/gdbm/test_gdbm.rb
test/logger/test_logger.rb
test/monitor/test_monitor.rb
+test/openssl/ssl_server.rb
+test/openssl/test_ssl.rb
test/openssl/test_x509cert.rb
test/openssl/test_x509crl.rb
test/openssl/test_x509name.rb
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index fdbd71bc0c..6fcb143fc8 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -54,14 +54,19 @@ module Buffering
public
- def read(size=nil)
+ def read(size=nil, buf=nil)
fill_rbuff unless defined? @rbuffer
@eof ||= nil
until @eof
break if size && size <= @rbuffer.size
fill_rbuff
end
- consume_rbuff(size)
+ ret = consume_rbuff(size) || ""
+ if buf
+ buf.replace(ret)
+ ret = buf
+ end
+ (size && ret.empty?) ? nil : ret
end
def gets(eol=$/)
@@ -164,7 +169,7 @@ module Buffering
s = ""
args.each{|arg|
s << arg.to_s
- unless /#{$/}\Z/o =~ s
+ unless /#{$/}\z/o =~ s
s << $/
end
}
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index 811a935509..629109a1de 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -14,7 +14,8 @@
$Id$
=end
-require 'openssl/buffering'
+require "openssl"
+require "openssl/buffering"
module OpenSSL
module SSL
@@ -42,6 +43,10 @@ module OpenSSL
def closed?
to_io.closed?
end
+
+ def do_not_reverse_lookup=(flag)
+ to_io.do_not_reverse_lookup = flag
+ end
end
class SSLSocket
@@ -63,7 +68,7 @@ module OpenSSL
@svr
end
- def listen(basklog=5)
+ def listen(backlog=5)
@svr.listen(backlog)
end
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index d115b3aeb4..031f2334f7 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -484,16 +484,22 @@ ossl_ssl_accept(VALUE self)
}
static VALUE
-ossl_ssl_read(VALUE self, VALUE len)
+ossl_ssl_read(int argc, VALUE *argv, VALUE self)
{
SSL *ssl;
int ilen, nread = 0;
- VALUE str;
+ VALUE len, str;
OpenFile *fptr;
Data_Get_Struct(self, SSL, ssl);
+ rb_scan_args(argc, argv, "11", &len, &str);
ilen = NUM2INT(len);
- str = rb_str_new(0, ilen);
+ if(NIL_P(str)) str = rb_str_new(0, ilen);
+ else{
+ StringValue(str);
+ rb_str_modify(str);
+ rb_str_resize(str, ilen);
+ }
if (ssl) {
for (;;){
@@ -730,7 +736,7 @@ Init_ossl_ssl()
rb_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1);
rb_define_method(cSSLSocket, "connect", ossl_ssl_connect, 0);
rb_define_method(cSSLSocket, "accept", ossl_ssl_accept, 0);
- rb_define_method(cSSLSocket, "sysread", ossl_ssl_read, 1);
+ rb_define_method(cSSLSocket, "sysread", ossl_ssl_read, -1);
rb_define_method(cSSLSocket, "syswrite", ossl_ssl_write, 1);
rb_define_method(cSSLSocket, "sysclose", ossl_ssl_close, 0);
rb_define_method(cSSLSocket, "cert", ossl_ssl_get_cert, 0);
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
index 3ca25cbfe1..55f7920313 100644
--- a/test/openssl/test_ssl.rb
+++ b/test/openssl/test_ssl.rb
@@ -61,7 +61,7 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
cmd << "-d" if $DEBUG
cmd << SSL_SERVER << port.to_s << verify_mode.to_s
cmd << (start_immediately ? "yes" : "no")
- server = IO.popen(cmd, "w+")
+ server = IO.popen(cmd.join(" "), "w+")
server.write(@ca_cert.to_pem)
server.write(@svr_cert.to_pem)
server.write(@svr_key.to_pem)
diff --git a/test/openssl/test_x509name.rb b/test/openssl/test_x509name.rb
index 0fbe2c2569..14004a4e20 100644
--- a/test/openssl/test_x509name.rb
+++ b/test/openssl/test_x509name.rb
@@ -76,12 +76,21 @@ class OpenSSL::TestX509Name < Test::Unit::TestCase
]
name = OpenSSL::X509::Name.new(dn)
ary = name.to_a
- assert_equal("/DC=org/DC=ruby-lang/CN=GOTOU Yuuzou/emailAddress=gotoyuzo@ruby-lang.org/serialNumber=123", name.to_s)
+ if OpenSSL::OPENSSL_VERSION_NUMBER < 0x00907000
+ assert_equal("/DC=org/DC=ruby-lang/CN=GOTOU Yuuzou/Email=gotoyuzo@ruby-lang.org/SN=123", name.to_s)
+ else
+ assert_equal("/DC=org/DC=ruby-lang/CN=GOTOU Yuuzou/emailAddress=gotoyuzo@ruby-lang.org/serialNumber=123", name.to_s)
+ end
assert_equal("DC", ary[0][0])
assert_equal("DC", ary[1][0])
assert_equal("CN", ary[2][0])
- assert_equal("emailAddress", ary[3][0])
- assert_equal("serialNumber", ary[4][0])
+ if OpenSSL::OPENSSL_VERSION_NUMBER < 0x00907000
+ assert_equal("Email", ary[3][0])
+ assert_equal("SN", ary[4][0])
+ else
+ assert_equal("emailAddress", ary[3][0])
+ assert_equal("serialNumber", ary[4][0])
+ end
assert_equal("org", ary[0][1])
assert_equal("ruby-lang", ary[1][1])
assert_equal("GOTOU Yuuzou", ary[2][1])
@@ -140,12 +149,21 @@ class OpenSSL::TestX509Name < Test::Unit::TestCase
name = OpenSSL::X509::Name.new
dn.each{|attr| name.add_entry(*attr) }
ary = name.to_a
- assert_equal("/DC=org/DC=ruby-lang/CN=GOTOU Yuuzou/emailAddress=gotoyuzo@ruby-lang.org/serialNumber=123", name.to_s)
+ if OpenSSL::OPENSSL_VERSION_NUMBER < 0x00907000
+ assert_equal("/DC=org/DC=ruby-lang/CN=GOTOU Yuuzou/Email=gotoyuzo@ruby-lang.org/SN=123", name.to_s)
+ else
+ assert_equal("/DC=org/DC=ruby-lang/CN=GOTOU Yuuzou/emailAddress=gotoyuzo@ruby-lang.org/serialNumber=123", name.to_s)
+ end
assert_equal("DC", ary[0][0])
assert_equal("DC", ary[1][0])
assert_equal("CN", ary[2][0])
- assert_equal("emailAddress", ary[3][0])
- assert_equal("serialNumber", ary[4][0])
+ if OpenSSL::OPENSSL_VERSION_NUMBER < 0x00907000
+ assert_equal("Email", ary[3][0])
+ assert_equal("SN", ary[4][0])
+ else
+ assert_equal("emailAddress", ary[3][0])
+ assert_equal("serialNumber", ary[4][0])
+ end
assert_equal("org", ary[0][1])
assert_equal("ruby-lang", ary[1][1])
assert_equal("GOTOU Yuuzou", ary[2][1])
diff --git a/test/openssl/test_x509store.rb b/test/openssl/test_x509store.rb
index d17a7133b2..0887bf6ea9 100644
--- a/test/openssl/test_x509store.rb
+++ b/test/openssl/test_x509store.rb
@@ -109,8 +109,7 @@ class OpenSSL::TestX509Store < Test::Unit::TestCase
store = OpenSSL::X509::Store.new
store.purpose = OpenSSL::X509::PURPOSE_ANY
- store.flags =
- OpenSSL::X509::V_FLAG_CRL_CHECK #|OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
+ store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK
store.add_cert(ca1_cert)
store.add_crl(crl1) # revoke no cert
store.add_crl(crl2) # revoke ee2_cert
diff --git a/test/openssl/utils.rb b/test/openssl/utils.rb
index 8c0d34c938..c923705b86 100644
--- a/test/openssl/utils.rb
+++ b/test/openssl/utils.rb
@@ -99,8 +99,8 @@ Q1VB8qkJN7rA7/2HrCR3gTsWNb1YhAsnFsoeRscC+LxXoXi9OAIUBG98h4tilg6S
def issue_crl(revoke_info, serial, lastup, nextup, extensions,
issuer, issuer_key, digest)
crl = OpenSSL::X509::CRL.new
- crl.version = 1
crl.issuer = issuer.subject
+ crl.version = 1
crl.last_update = lastup
crl.next_update = nextup
revoke_info.each{|serial, time, reason_code|