Module: IIRC::SSL

Defined in:
lib/iirc.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_contextObject



82
83
84
# File 'lib/iirc.rb', line 82

def default_context
  verify_peer_and_hostname
end

.no_verifyObject



105
106
107
108
# File 'lib/iirc.rb', line 105

def no_verify
  require 'openssl'
  OpenSSL::SSL::SSLContext.new
end

.verify_hostname_onlyObject



99
100
101
102
103
# File 'lib/iirc.rb', line 99

def verify_hostname_only
  no_verify.tap { |context|
    context.verify_hostname = true
  }
end

.verify_peerObject



92
93
94
95
96
97
# File 'lib/iirc.rb', line 92

def verify_peer
  no_verify.tap { |context|
    context.verify_mode = OpenSSL::SSL::VERIFY_PEER
    context.cert_store = OpenSSL::X509::Store.new.tap(&:set_default_paths)
  }
end

.verify_peer_and_hostnameObject



86
87
88
89
90
# File 'lib/iirc.rb', line 86

def verify_peer_and_hostname
  verify_peer.tap { |context|
    context.verify_hostname = true
  }
end

Instance Method Details

#default_contextObject (private)



82
83
84
# File 'lib/iirc.rb', line 82

def default_context
  verify_peer_and_hostname
end

#no_verifyObject (private)



105
106
107
108
# File 'lib/iirc.rb', line 105

def no_verify
  require 'openssl'
  OpenSSL::SSL::SSLContext.new
end

#verify_hostname_onlyObject (private)



99
100
101
102
103
# File 'lib/iirc.rb', line 99

def verify_hostname_only
  no_verify.tap { |context|
    context.verify_hostname = true
  }
end

#verify_peerObject (private)



92
93
94
95
96
97
# File 'lib/iirc.rb', line 92

def verify_peer
  no_verify.tap { |context|
    context.verify_mode = OpenSSL::SSL::VERIFY_PEER
    context.cert_store = OpenSSL::X509::Store.new.tap(&:set_default_paths)
  }
end

#verify_peer_and_hostnameObject (private)



86
87
88
89
90
# File 'lib/iirc.rb', line 86

def verify_peer_and_hostname
  verify_peer.tap { |context|
    context.verify_hostname = true
  }
end