From b830786f2d025dac69db636f10ed6107d50ee068 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Wed, 5 Aug 2015 22:55:38 +0000 Subject: * ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move OpenSSL::SSL::SSLSocket#initialize to Ruby. * ext/openssl/ossl_ssl.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/lib/openssl/ssl.rb | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'ext/openssl/lib') diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb index cfa2a0c117..8fba3ee369 100644 --- a/ext/openssl/lib/openssl/ssl.rb +++ b/ext/openssl/lib/openssl/ssl.rb @@ -94,6 +94,15 @@ module OpenSSL attr_accessor :tmp_dh_callback + if ExtConfig::HAVE_TLSEXT_HOST_NAME + # A callback invoked at connect time to distinguish between multiple + # server names. + # + # The callback is invoked with an SSLSocket and a server name. The + # callback must return an SSLContext for the server name or nil. + attr_accessor :servername_cb + end + # call-seq: # SSLContext.new => ctx # SSLContext.new(:TLSv1) => ctx @@ -253,6 +262,42 @@ module OpenSSL include SocketForwarder include Nonblock + if ExtConfig::OPENSSL_NO_SOCK + def initialize(io, ctx = nil); raise NotImplmentedError; end + else + if ExtConfig::HAVE_TLSEXT_HOST_NAME + attr_accessor :hostname + end + + attr_reader :io, :context + attr_accessor :sync_close + alias :to_io :io + + # call-seq: + # SSLSocket.new(io) => aSSLSocket + # SSLSocket.new(io, ctx) => aSSLSocket + # + # Creates a new SSL socket from +io+ which must be a real ruby object (not an + # IO-like object that responds to read/write). + # + # If +ctx+ is provided the SSL Sockets initial params will be taken from + # the context. + # + # The OpenSSL::Buffering module provides additional IO methods. + # + # This method will freeze the SSLContext if one is provided; + # however, session management is still allowed in the frozen SSLContext. + + def initialize(io, context = OpenSSL::SSL::SSLContext.new) + @io = io + @context = context + @sync_close = false + @hostname = nil + context.setup + super() + end + end + ## # Perform hostname verification after an SSL connection is established # -- cgit v1.2.3