aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/openssl/ossl_ssl.c2
-rw-r--r--test/openssl/test_ssl.rb4
3 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8489a54691..5379760e0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Nov 15 06:43:48 2010 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * etc/openssl/ossl_ssl.c (ossl_ssl_get_cert): raise exception if
+ pointer is invalid. Thanks Ippei Obayashi! [ruby-dev:42573]
+
Sun Nov 14 17:57:45 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enc/Makefile.in (distclean): should not remove sources which are
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index a690202258..ea6e04b55a 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1337,7 +1337,7 @@ ossl_ssl_get_cert(VALUE self)
X509 *cert = NULL;
Data_Get_Struct(self, SSL, ssl);
- if (ssl) {
+ if (!ssl) {
rb_warning("SSL session is not started yet.");
return Qnil;
}
diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb
index 73c35c0749..2d56a7058c 100644
--- a/test/openssl/test_ssl.rb
+++ b/test/openssl/test_ssl.rb
@@ -160,6 +160,10 @@ class OpenSSL::TestSSL < Test::Unit::TestCase
assert_equal(ctx.setup, nil)
end
+ def test_not_started_session
+ OpenSSL::SSL::SSLSocket.new(STDIN).cert
+ end
+
def test_ssl_read_nonblock
start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true) { |server, port|
sock = TCPSocket.new("127.0.0.1", port)