Class: HTTPClient::SSLSocketWrap
- Inherits:
-
Object
- Object
- HTTPClient::SSLSocketWrap
- Defined in:
- lib/httpclient.rb
Overview
HTTPClient::SSLSocketWrap
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #addr ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
- #eof? ⇒ Boolean
- #flush ⇒ Object
- #gets(*args) ⇒ Object
-
#initialize(socket, context, debug_dev = nil) ⇒ SSLSocketWrap
constructor
A new instance of SSLSocketWrap.
- #peer_cert ⇒ Object
- #post_connection_check(host) ⇒ Object
- #read(*args) ⇒ Object
- #ssl_connect ⇒ Object
- #sync ⇒ Object
- #sync=(sync) ⇒ Object
Constructor Details
#initialize(socket, context, debug_dev = nil) ⇒ SSLSocketWrap
Returns a new instance of SSLSocketWrap.
938 939 940 941 942 943 944 945 946 947 |
# File 'lib/httpclient.rb', line 938 def initialize(socket, context, debug_dev = nil) unless SSLEnabled raise RuntimeError.new( "Ruby/OpenSSL module is required for https access.") end @context = context @socket = socket @ssl_socket = create_ssl_socket(@socket) @debug_dev = debug_dev end |
Instance Method Details
#<<(str) ⇒ Object
1007 1008 1009 1010 1011 |
# File 'lib/httpclient.rb', line 1007 def <<(str) rv = @ssl_socket.write(str) @debug_dev << str if @debug_dev rv end |
#addr ⇒ Object
978 979 980 |
# File 'lib/httpclient.rb', line 978 def addr @socket.addr end |
#close ⇒ Object
982 983 984 985 |
# File 'lib/httpclient.rb', line 982 def close @ssl_socket.close @socket.close end |
#closed? ⇒ Boolean
987 988 989 |
# File 'lib/httpclient.rb', line 987 def closed? @socket.closed? end |
#eof? ⇒ Boolean
991 992 993 |
# File 'lib/httpclient.rb', line 991 def eof? @ssl_socket.eof? end |
#flush ⇒ Object
1013 1014 1015 |
# File 'lib/httpclient.rb', line 1013 def flush @ssl_socket.flush end |
#gets(*args) ⇒ Object
995 996 997 998 999 |
# File 'lib/httpclient.rb', line 995 def gets(*args) str = @ssl_socket.gets(*args) @debug_dev << str if @debug_dev str end |
#peer_cert ⇒ Object
974 975 976 |
# File 'lib/httpclient.rb', line 974 def peer_cert @ssl_socket.peer_cert end |
#post_connection_check(host) ⇒ Object
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 |
# File 'lib/httpclient.rb', line 953 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, "no peer cert" end hostname = host.host # if @ssl_socket.respond_to?(:post_connection_check) # ## modified by =vg to catch wildcard hostnames # begin # @ssl_socket.post_connection_check(hostname) # rescue OpenSSL::SSL::SSLError # @ssl_socket.post_connection_check(hostname.sub(/^[^.]+/, '*')) # end # else @context.post_connection_check(@ssl_socket.peer_cert, hostname) # end end |
#read(*args) ⇒ Object
1001 1002 1003 1004 1005 |
# File 'lib/httpclient.rb', line 1001 def read(*args) str = @ssl_socket.read(*args) @debug_dev << str if @debug_dev str end |
#ssl_connect ⇒ Object
949 950 951 |
# File 'lib/httpclient.rb', line 949 def ssl_connect @ssl_socket.connect end |
#sync ⇒ Object
1017 1018 1019 |
# File 'lib/httpclient.rb', line 1017 def sync @ssl_socket.sync end |
#sync=(sync) ⇒ Object
1021 1022 1023 |
# File 'lib/httpclient.rb', line 1021 def sync=(sync) @ssl_socket.sync = sync end |