透明思考


Transparent Thoughts


JRuby/LDAP over SSL

Integrating ActiveDirectory with JRuby on Rails. Blocked bySSLissue. (Actually not AD butADAM. Checkhow to configureADAMforSSLon Windows XP without a certificate server)

Jeff: Here we have a question about JRuby/LDAP: how to establish SSLConn to ActiveDirectory,given wehave got the certificate file (xxx.cer)?

Ola: Very good question. At the moment I don’t have the answer – and I’m notsure it’spossible. Have you considered using net/ldap instead? It’s pure Ruby and very nice.

(╯﹏╰)

And then I figured it out. What we need is (1) import the certificate to a keystore, and (2) specifythe location ofkeystore to JRuby.

# command linekeytool -keystore “./cacerts” -import -file Authority.cer# JRubyjava.lang.System::setProperty(“javax.net.ssl.trustStore”, “/path/to/cacerts”);

And…that’s it. Now we can connect toADAMoverSSL.

conn = LDAP::SSLConn.new(host=LDAP_HOST, port=636)