Wraps up OpenSSL::SSL::SSLSocket and offers debugging features.
# File lib/httpclient/session.rb, line 288 def initialize(socket, context, debug_dev = nil) unless SSLEnabled raise ConfigurationError.new('Ruby/OpenSSL module is required') end @context = context @socket = socket @ssl_socket = create_openssl_socket(@socket) @debug_dev = debug_dev end
# File lib/httpclient/session.rb, line 368 def <<(str) rv = @ssl_socket.write(str) debug(str) rv end
# File lib/httpclient/session.rb, line 337 def close @ssl_socket.close @socket.close end
# File lib/httpclient/session.rb, line 342 def closed? @socket.closed? end
# File lib/httpclient/session.rb, line 346 def eof? @ssl_socket.eof? end
# File lib/httpclient/session.rb, line 374 def flush @ssl_socket.flush end
# File lib/httpclient/session.rb, line 350 def gets(*args) str = @ssl_socket.gets(*args) debug(str) str end
# File lib/httpclient/session.rb, line 333 def peer_cert @ssl_socket.peer_cert end
# File lib/httpclient/session.rb, line 305 def post_connection_check(host) verify_mode = @context.verify_mode || OpenSSL::SSL::VERIFY_NONE if verify_mode == OpenSSL::SSL::VERIFY_NONE return elsif @ssl_socket.peer_cert.nil? and check_mask(verify_mode, OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT) raise OpenSSL::SSL::SSLError.new('no peer cert') end hostname = host.host if @ssl_socket.respond_to?(:post_connection_check) and RUBY_VERSION > "1.8.4" @ssl_socket.post_connection_check(hostname) else @context.post_connection_check(@ssl_socket.peer_cert, hostname) end end
# File lib/httpclient/session.rb, line 356 def read(*args) str = @ssl_socket.read(*args) debug(str) str end
# File lib/httpclient/session.rb, line 362 def readpartial(*args) str = @ssl_socket.readpartial(*args) debug(str) str end
# File lib/httpclient/session.rb, line 325 def ssl_cipher @ssl_socket.cipher end
# File lib/httpclient/session.rb, line 298 def ssl_connect(hostname = nil) if hostname && @ssl_socket.respond_to?(:hostname=) @ssl_socket.hostname = hostname end @ssl_socket.connect end
# File lib/httpclient/session.rb, line 329 def ssl_state @ssl_socket.state end
# File lib/httpclient/session.rb, line 321 def ssl_version @ssl_socket.ssl_version if @ssl_socket.respond_to?(:ssl_version) end
# File lib/httpclient/session.rb, line 378 def sync @ssl_socket.sync end
# File lib/httpclient/session.rb, line 382 def sync=(sync) @ssl_socket.sync = sync end