Class: HTTPClient::SSLSocketWrap
- Inherits:
-
Object
- Object
- HTTPClient::SSLSocketWrap
- Defined in:
- lib/httpclient/session.rb
Overview
Wraps up OpenSSL::SSL::SSLSocket and offers debugging features.
Instance Method Summary collapse
- #<<(str) ⇒ 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
- #readpartial(*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.
254 255 256 257 258 259 260 261 262 |
# File 'lib/httpclient/session.rb', line 254 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 |
Instance Method Details
#<<(str) ⇒ Object
319 320 321 322 323 |
# File 'lib/httpclient/session.rb', line 319 def <<(str) rv = @ssl_socket.write(str) debug(str) rv end |
#close ⇒ Object
288 289 290 291 |
# File 'lib/httpclient/session.rb', line 288 def close @ssl_socket.close @socket.close end |
#closed? ⇒ Boolean
293 294 295 |
# File 'lib/httpclient/session.rb', line 293 def closed? @socket.closed? end |
#eof? ⇒ Boolean
297 298 299 |
# File 'lib/httpclient/session.rb', line 297 def eof? @ssl_socket.eof? end |
#flush ⇒ Object
325 326 327 |
# File 'lib/httpclient/session.rb', line 325 def flush @ssl_socket.flush end |
#gets(*args) ⇒ Object
301 302 303 304 305 |
# File 'lib/httpclient/session.rb', line 301 def gets(*args) str = @ssl_socket.gets(*args) debug(str) str end |
#peer_cert ⇒ Object
284 285 286 |
# File 'lib/httpclient/session.rb', line 284 def peer_cert @ssl_socket.peer_cert end |
#post_connection_check(host) ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/httpclient/session.rb', line 268 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 |
#read(*args) ⇒ Object
307 308 309 310 311 |
# File 'lib/httpclient/session.rb', line 307 def read(*args) str = @ssl_socket.read(*args) debug(str) str end |
#readpartial(*args) ⇒ Object
313 314 315 316 317 |
# File 'lib/httpclient/session.rb', line 313 def readpartial(*args) str = @ssl_socket.readpartial(*args) debug(str) str end |
#ssl_connect ⇒ Object
264 265 266 |
# File 'lib/httpclient/session.rb', line 264 def ssl_connect @ssl_socket.connect end |
#sync ⇒ Object
329 330 331 |
# File 'lib/httpclient/session.rb', line 329 def sync @ssl_socket.sync end |
#sync=(sync) ⇒ Object
333 334 335 |
# File 'lib/httpclient/session.rb', line 333 def sync=(sync) @ssl_socket.sync = sync end |