SSL enabled or disabled per presence of OpenSSL.
This commit is contained in:
parent
c3f991fdf8
commit
e31af4bead
2 changed files with 16 additions and 1 deletions
|
@ -1,5 +1,15 @@
|
|||
require 'openssl'
|
||||
require 'ostruct'
|
||||
|
||||
module Net
|
||||
class LDAP
|
||||
begin
|
||||
require 'openssl'
|
||||
HasOpenSSL = true
|
||||
rescue LoadError
|
||||
HasOpenSSL = false
|
||||
end
|
||||
end
|
||||
end
|
||||
require 'socket'
|
||||
|
||||
require 'net/ber'
|
||||
|
@ -1141,6 +1151,7 @@ module Net
|
|||
end
|
||||
|
||||
def self.wrap_with_ssl(io)
|
||||
raise Net::LDAP::LdapError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
|
||||
ctx = OpenSSL::SSL::SSLContext.new
|
||||
conn = OpenSSL::SSL::SSLSocket.new(io, ctx)
|
||||
conn.connect
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue