 @@ -36,8 +36,8 @@ VALUE cSSLSocket;
  static VALUE eSSLErrorWaitReadable;
  static VALUE eSSLErrorWaitWritable;
- 
+
 -#define ossl_sslctx_set_cert(o,v)        	rb_iv_set((o),"@cert",(v))
 -#define ossl_sslctx_set_key(o,v)         	rb_iv_set((o),"@key",(v))
 +#define ossl_sslctx_set_certs(o,v)        	rb_iv_set((o),"@certs",(v))

@@ -70,7 +70,7 @@ class SSLContext
         DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
       end
 
-      INIT_VARS = ["cert", "key", "client_ca", "ca_file", "ca_path",
+      INIT_VARS = ["client_ca", "ca_file", "ca_path",
         "timeout", "verify_mode", "verify_depth", "renegotiation_cb",
         "verify_callback", "cert_store", "extra_chain_cert",
         "client_cert_cb", "session_id_context", "tmp_dh_callback",
@@ -106,6 +106,7 @@ class SSLContext
       #
       # You can get a list of valid methods with OpenSSL::SSL::SSLContext::METHODS
       def initialize(version = nil, fallback_scsv: false)
+        @certs = @keys = []
         INIT_VARS.each { |v| instance_variable_set v, nil }
         self.options = self.options | OpenSSL::SSL::OP_ALL
         return unless version

-    VALUE val;
+    VALUE val, val2;
+    int cert_defined = 0, key_defined = 0;

     if(OBJ_FROZEN(self)) return Qnil;
     GetSSLCTX(self, ctx);
@@ -761,19 +762,39 @@ ossl_sslctx_setup(VALUE self)
     }

     /* private key may be bundled in certificate file. */
-    val = ossl_sslctx_get_cert(self);
-    cert = NIL_P(val) ? NULL : GetX509CertPtr(val); /* NO DUP NEEDED */
