我正在使用https://github.com/ruby-ldap/ruby-net-ldap (Net) gem来验证rails应用程序中用户的真实性。但是,在将数据传递到ldap服务器之前,我需要验证是否与同一个安全服务器进行了交谈。有什么办法可以让我用ruby验证证书吗?
其他细节:(我尝试过的东西)
发布于 2014-04-02 11:31:04
为了完整起见,我在这里张贴我的解决方案。
net-ldap创业板覆盖以支持证书验证https://gist.github.com/mintuhouse/9931865。
理想解决方案:
在您的服务器上维护受信任的根CA列表(如果您像我一样懒惰,请执行cron作业,它将从http://curl.haxx.se/ca/cacert.pem下载(每周由curl维护)副本)
重写Net::HTTP始终使用此受信任的证书列表
发布于 2016-12-19 22:03:02
截止到今天(2016年末),支持这个上游!但是,需要传递tls_options,并将verify_mode设置为默认VERIFY_NONE以外的值。
# optional: create/pass your own cert_store
cert_store = OpenSSL::X509::Store.new
cert_store.set_default_paths # or add your own CAdir, &c.
# attributes documented for OpenSSL::SSL::SSLContext are valid here
tls_options = {
verify_mode: OpenSSL::SSL::VERIFY_PEER
cert_store: cert_store
}
ldap = Net::LDAP.new(
:host => host,
:port => port,
:encryption => {
:method => :simple_tls, # could also be :start_tls
:tls_options => tls_options
}
)https://stackoverflow.com/questions/18759483
复制相似问题