Class: OpenSSL::SSL::SSLSocket
- Includes:
- Buffering, SocketForwarder
- Defined in:
- lib/extensions/openssl/openssl/ssl.rb
Constant Summary
Constants included from Buffering
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
The SSLContext object used in this connection.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#io ⇒ Object
(also: #to_io)
readonly
The underlying IO object.
-
#sync_close ⇒ Object
Whether to close the underlying socket as well, when the SSL/TLS connection is shut down.
Attributes included from Buffering
Instance Method Summary collapse
-
#post_connection_check(hostname) ⇒ Object
call-seq: ssl.post_connection_check(hostname) -> true.
-
#session ⇒ Object
call-seq: ssl.session -> aSession.
-
#sysclose ⇒ Object
call-seq: ssl.sysclose => nil.
Methods included from SocketForwarder
#addr, #closed?, #do_not_reverse_lookup=, #fcntl, #getsockopt, #peeraddr, #setsockopt
Methods included from Buffering
#<<, #close, #each, #each_byte, #eof?, #flush, #getc, #gets, #initialize, #print, #printf, #puts, #read, #read_nonblock, #readchar, #readline, #readlines, #readpartial, #ungetc, #write, #write_nonblock
Methods included from Enumerable
Instance Attribute Details
#context ⇒ Object (readonly)
The SSLContext object used in this connection.
254 255 256 |
# File 'lib/extensions/openssl/openssl/ssl.rb', line 254 def context @context end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
246 247 248 |
# File 'lib/extensions/openssl/openssl/ssl.rb', line 246 def hostname @hostname end |
#io ⇒ Object (readonly) Also known as: to_io
The underlying IO object.
250 251 252 |
# File 'lib/extensions/openssl/openssl/ssl.rb', line 250 def io @io end |
#sync_close ⇒ Object
Whether to close the underlying socket as well, when the SSL/TLS connection is shut down. This defaults to false.
258 259 260 |
# File 'lib/extensions/openssl/openssl/ssl.rb', line 258 def sync_close @sync_close end |
Instance Method Details
#post_connection_check(hostname) ⇒ Object
call-seq:
ssl.post_connection_check(hostname) -> true
Perform hostname verification following RFC 6125.
This method MUST be called after calling #connect to ensure that the hostname of a remote peer has been verified.
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/extensions/openssl/openssl/ssl.rb', line 280 def post_connection_check(hostname) if peer_cert.nil? msg = "Peer verification enabled, but no certificate received." if using_anon_cipher? msg += " Anonymous cipher suite #{cipher[0]} was negotiated. " \ "Anonymous suites must be disabled to use peer verification." end raise SSLError, msg end unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname) raise SSLError, "hostname \"#{hostname}\" does not match the server certificate" end return true end |
#session ⇒ Object
call-seq:
ssl.session -> aSession
Returns the SSLSession object currently used, or nil if the session is not established.
301 302 303 304 305 |
# File 'lib/extensions/openssl/openssl/ssl.rb', line 301 def session SSL::Session.new(self) rescue SSL::Session::SessionError nil end |
#sysclose ⇒ Object
call-seq:
ssl.sysclose => nil
Sends “close notify” to the peer and tries to shut down the SSL connection gracefully.
If sync_close is set to true, the underlying IO is also closed.
267 268 269 270 271 |
# File 'lib/extensions/openssl/openssl/ssl.rb', line 267 def sysclose return if closed? stop io.close if sync_close end |