Class: X509Sleuth::Client
- Inherits:
-
Object
- Object
- X509Sleuth::Client
- Defined in:
- lib/x509_sleuth/client.rb
Instance Attribute Summary collapse
-
#connect_error ⇒ Object
readonly
Returns the value of attribute connect_error.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#timeout_secs ⇒ Object
readonly
Returns the value of attribute timeout_secs.
Instance Method Summary collapse
- #connect ⇒ Object
- #connect_failed? ⇒ Boolean
-
#initialize(host, options = {}) ⇒ Client
constructor
A new instance of Client.
- #peer_certificate ⇒ Object
- #ssl_socket ⇒ Object
- #tcp_socket ⇒ Object
Constructor Details
#initialize(host, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/x509_sleuth/client.rb', line 9 def initialize(host, = {}) = { port: 443, timeout_secs: 15 }.merge() @host = host @port = [:port] @timeout_secs = [:timeout_secs] end |
Instance Attribute Details
#connect_error ⇒ Object (readonly)
Returns the value of attribute connect_error.
7 8 9 |
# File 'lib/x509_sleuth/client.rb', line 7 def connect_error @connect_error end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/x509_sleuth/client.rb', line 7 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/x509_sleuth/client.rb', line 7 def port @port end |
#timeout_secs ⇒ Object (readonly)
Returns the value of attribute timeout_secs.
7 8 9 |
# File 'lib/x509_sleuth/client.rb', line 7 def timeout_secs @timeout_secs end |
Instance Method Details
#connect ⇒ Object
30 31 32 33 34 |
# File 'lib/x509_sleuth/client.rb', line 30 def connect Timeout::timeout(@timeout_secs) { ssl_socket.connect } rescue SystemCallError, SocketError, OpenSSL::SSL::SSLError, Timeout::Error => e @connect_error = e end |
#connect_failed? ⇒ Boolean
36 37 38 |
# File 'lib/x509_sleuth/client.rb', line 36 def connect_failed? connect_error ? true : false end |
#peer_certificate ⇒ Object
40 41 42 |
# File 'lib/x509_sleuth/client.rb', line 40 def peer_certificate @peer_certficate ||= ssl_socket.peer_cert end |
#ssl_socket ⇒ Object
24 25 26 27 28 |
# File 'lib/x509_sleuth/client.rb', line 24 def ssl_socket @ssl_socket ||= OpenSSL::SSL::SSLSocket.new(tcp_socket) @ssl_socket.hostname = @host @ssl_socket end |
#tcp_socket ⇒ Object
20 21 22 |
# File 'lib/x509_sleuth/client.rb', line 20 def tcp_socket @tcp_socket ||= TCPSocket.new(@host, @port) end |