cschiewek / devise_ldap_authenticatable

Devise Module for LDAP
MIT License
594 stars 359 forks source link

0.8.6 - ldap error: hostname does not match the server certificate #251

Open patrick99e99 opened 6 years ago

patrick99e99 commented 6 years ago

When I use 0.8.5, if I try to authenticate I see:

irb(main):002:0> u.valid_ldap_authentication?('foobar')
  LDAP: LDAP dn lookup: uid=patrick
  LDAP: LDAP search for login: uid=patrick
  LDAP: LDAP search yielded 1 matches
  LDAP: Authorizing user uid=PCollins,object=orgperson,dv=so_runner,dv=syncobjectcatalog
  LDAP: Not authorized because not authenticated.

But then when I upgrade to 0.8.6, I now get:

irb(main):002:0> u.valid_ldap_authentication?('foobar')
  LDAP: LDAP dn lookup: uid=patrick
  LDAP: LDAP search for login: uid=patrick
Traceback (most recent call last):
       16: from (irb):2
       15: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/devise_ldap_authenticatable-0.8.6/lib/devise_ldap_authenticatable/model.rb:48:in `valid_ldap_authentication?'
       14: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/devise_ldap_authenticatable-0.8.6/lib/devise_ldap_authenticatable/ldap/adapter.rb:15:in `valid_credentials?'
       13: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/devise_ldap_authenticatable-0.8.6/lib/devise_ldap_authenticatable/ldap/connection.rb:97:in `authorized?'
       12: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/devise_ldap_authenticatable-0.8.6/lib/devise_ldap_authenticatable/ldap/connection.rb:51:in `dn'
       11: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/devise_ldap_authenticatable-0.8.6/lib/devise_ldap_authenticatable/ldap/connection.rb:239:in `search_for_login'
       10: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap.rb:775:in `search'
        9: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap.rb:1273:in `paged_searches_supported?'
        8: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap.rb:1207:in `search_root_dse'
        7: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap.rb:782:in `search'
        6: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap/instrumentation.rb:19:in `instrument'
        5: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap.rb:783:in `block in search'
        4: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap.rb:1300:in `use_connection'
        3: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap.rb:1321:in `new_connection'
        2: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap/connection.rb:698:in `socket'
        1: from /srv/www/myapp/shared/vendor/bundle/ruby/2.5.0/gems/net-ldap-0.16.1/lib/net/ldap/connection.rb:72:in `open_connection'
Net::LDAP::Error (hostname "10.255.5.15" does not match the server certificate)

What can I do to resolve this?

xtrasimplicity commented 6 years ago

Net::LDAP::Error (hostname "10.255.5.15" does not match the server certificate)

Does your LDAP server have 10.255.5.15 as a CN or SAN in the SSL certificate?

kuzevanoff commented 5 years ago

I have the same error, how I can solve it ? I need to ignore server certificate verification

marcoadkins commented 5 years ago

I am also seeing the same failure after upgrading from 0.8.5 to 0.8.6. Resolved by locking my gemfile to 0.8.5.

blackham commented 4 years ago

Just my 0.02. Locking the gem to 0.8.5 solved my errors too. But it looks like the error is in Net::LDAP.

Not sure yet what changed in net-ldap but downgrading net-ldap from 0.16.2 to 0.11 made my connection happy. (Which of course is done when downgrading devise_ldap_authenticatable to 0.8.5)