Created
March 3, 2015 22:02
-
-
Save dnozay/ee3d67769adbe699cb29 to your computer and use it in GitHub Desktop.
test LDAPS connection using TLS 1.1 and internal CA certificate validation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test LDAPS connection using TLS 1.1 and internal CA certificate validation. | |
require 'rubygems' | |
require 'net/ldap' | |
# refs: | |
# https://gist.github.com/jeffjohnson9046/7012167 | |
# https://github.com/ruby-ldap/ruby-net-ldap/blob/master/lib/net/ldap.rb | |
def get_ldap_response(ldap) | |
msg = "Response Code: #{ ldap.get_operation_result.code }, Message: #{ ldap.get_operation_result.message }" | |
# raise msg unless ldap.get_operation_result.code == 0 | |
print msg | |
end | |
ldap = Net::LDAP.new({ | |
:host => 'ldap.example.com', | |
:port => 636, | |
:encryption => { | |
:method => :simple_tls, | |
:tls_options => { | |
:ssl_version => "TLSv1_1", | |
:ca_file => '/etc/pki/ca-trust/source/anchors/internalCA.pem' | |
} | |
}, | |
:base => 'dc=example,dc=com', | |
:auth => { | |
:method => :simple, | |
:username => 'uid=testaccount,ou=users,dc=example,dc=com', | |
:password => 'testpassword!' | |
} | |
}) | |
ldap.bind | |
get_ldap_response(ldap) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment