aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ext/openssl/ossl_ssl.c19
-rw-r--r--ext/openssl/ossl_ssl.h4
-rw-r--r--ext/openssl/ossl_ssl_session.c11
-rw-r--r--lib/openssl/ssl.rb2
-rw-r--r--test/test_pair.rb2
-rw-r--r--test/test_ssl.rb2
-rw-r--r--test/test_ssl_session.rb2
-rw-r--r--test/utils.rb2
8 files changed, 36 insertions, 8 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index c0063d69..3949a8a6 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -11,6 +11,8 @@
*/
#include "ossl.h"
+#if !defined(OPENSSL_NO_SOCK)
+
#define numberof(ary) (int)(sizeof(ary)/sizeof((ary)[0]))
#ifdef _WIN32
@@ -1383,7 +1385,6 @@ ossl_sslctx_flush_sessions(int argc, VALUE *argv, VALUE self)
/*
* SSLSocket class
*/
-#ifndef OPENSSL_NO_SOCK
static inline int
ssl_started(SSL *ssl)
{
@@ -2246,7 +2247,6 @@ ossl_ssl_tmp_key(VALUE self)
return ossl_pkey_new(key);
}
# endif /* defined(HAVE_SSL_GET_SERVER_TMP_KEY) */
-#endif /* !defined(OPENSSL_NO_SOCK) */
#undef rb_intern
#define rb_intern(s) rb_intern_const(s)
@@ -2627,11 +2627,6 @@ Init_ossl_ssl(void)
* Document-class: OpenSSL::SSL::SSLSocket
*/
cSSLSocket = rb_define_class_under(mSSL, "SSLSocket", rb_cObject);
-#ifdef OPENSSL_NO_SOCK
- rb_define_const(mSSLExtConfig, "OPENSSL_NO_SOCK", Qtrue);
- rb_define_method(cSSLSocket, "initialize", rb_f_notimplement, -1);
-#else
- rb_define_const(mSSLExtConfig, "OPENSSL_NO_SOCK", Qfalse);
rb_define_alloc_func(cSSLSocket, ossl_ssl_s_alloc);
rb_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1);
rb_undef_method(cSSLSocket, "initialize_copy");
@@ -2667,7 +2662,6 @@ Init_ossl_ssl(void)
# ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
rb_define_method(cSSLSocket, "npn_protocol", ossl_ssl_npn_protocol, 0);
# endif
-#endif
#define ossl_ssl_def_const(x) rb_define_const(mSSL, #x, LONG2NUM(SSL_##x))
@@ -2748,3 +2742,12 @@ Init_ossl_ssl(void)
DefIVarID(context);
DefIVarID(hostname);
}
+
+#else /* !defined(OPENSSL_NO_SOCK) */
+
+void
+Init_ossl_ssl(void)
+{
+}
+
+#endif /* !defined(OPENSSL_NO_SOCK) */
diff --git a/ext/openssl/ossl_ssl.h b/ext/openssl/ossl_ssl.h
index c1a3cd6c..611ac7ba 100644
--- a/ext/openssl/ossl_ssl.h
+++ b/ext/openssl/ossl_ssl.h
@@ -10,6 +10,8 @@
#if !defined(_OSSL_SSL_H_)
#define _OSSL_SSL_H_
+#if !defined(OPENSSL_NO_SOCK)
+
#define GetSSL(obj, ssl) do { \
TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
if (!(ssl)) { \
@@ -35,6 +37,8 @@ extern VALUE mSSL;
extern VALUE cSSLSocket;
extern VALUE cSSLSession;
+#endif
+
void Init_ossl_ssl(void);
void Init_ossl_ssl_session(void);
diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c
index fefbf28b..8b1f7246 100644
--- a/ext/openssl/ossl_ssl_session.c
+++ b/ext/openssl/ossl_ssl_session.c
@@ -4,6 +4,8 @@
#include "ossl.h"
+#if !defined(OPENSSL_NO_SOCK)
+
VALUE cSSLSession;
static VALUE eSSLSession;
@@ -330,3 +332,12 @@ void Init_ossl_ssl_session(void)
rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
}
+
+#else /* !defined(OPENSSL_NO_SOCK) */
+
+void
+Init_ossl_ssl_session(void)
+{
+}
+
+#endif /* !defined(OPENSSL_NO_SOCK) */
diff --git a/lib/openssl/ssl.rb b/lib/openssl/ssl.rb
index c255789e..73ab5846 100644
--- a/lib/openssl/ssl.rb
+++ b/lib/openssl/ssl.rb
@@ -13,6 +13,7 @@
require "openssl/buffering"
require "io/nonblock"
+if defined?(OpenSSL::SSL) # OPENSSL_NO_SOCK
module OpenSSL
module SSL
class SSLContext
@@ -429,3 +430,4 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
end
end
end
+end
diff --git a/test/test_pair.rb b/test/test_pair.rb
index a462891d..0cdd5599 100644
--- a/test/test_pair.rb
+++ b/test/test_pair.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: false
require_relative 'utils'
+if defined?(OpenSSL::SSL) # OPENSSL_NO_SOCK
require 'socket'
require_relative 'ut_eof'
@@ -487,3 +488,4 @@ class OpenSSL::TestPairLowlevelSocket < OpenSSL::TestCase
include OpenSSL::SSLPairLowlevelSocket
include OpenSSL::TestPairM
end
+end # defined?(OpenSSL::SSL)
diff --git a/test/test_ssl.rb b/test/test_ssl.rb
index 23c9ef54..02d15da7 100644
--- a/test/test_ssl.rb
+++ b/test/test_ssl.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: false
require_relative "utils"
+if defined?(OpenSSL::SSL) # OPENSSL_NO_SOCK
class OpenSSL::TestSSL < OpenSSL::SSLTestCase
def test_ctx_options
@@ -1309,3 +1310,4 @@ end
}
end
end
+end # defined?(OpenSSL::SSL)
diff --git a/test/test_ssl_session.rb b/test/test_ssl_session.rb
index 2f633b03..005fbefc 100644
--- a/test/test_ssl_session.rb
+++ b/test/test_ssl_session.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: false
require_relative "utils"
+if defined?(OpenSSL::SSL)
class OpenSSL::TestSSLSession < OpenSSL::SSLTestCase
def test_session_equals
session = OpenSSL::SSL::Session.new <<-SESSION
@@ -374,3 +375,4 @@ __EOS__
assert_equal(sess_orig.to_der, sess_dup.to_der)
end
end
+end # defined?(OpenSSL::SSL)
diff --git a/test/utils.rb b/test/utils.rb
index 28922de0..95b693ab 100644
--- a/test/utils.rb
+++ b/test/utils.rb
@@ -145,6 +145,7 @@ module OpenSSL::TestUtils
end
end
+ if defined?(OpenSSL::SSL)
class OpenSSL::SSLTestCase < OpenSSL::TestCase
RUBY = EnvUtil.rubybin
ITERATIONS = ($0 == __FILE__) ? 100 : 10
@@ -259,6 +260,7 @@ module OpenSSL::TestUtils
}
end
end
+ end # defined?(OpenSSL::SSL)
class OpenSSL::PKeyTestCase < OpenSSL::TestCase
def check_component(base, test, keys)