Skip to content

Implement custom tls options #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 26, 2014
Merged

Implement custom tls options #161

merged 3 commits into from
Nov 26, 2014

Conversation

sonOfRa
Copy link
Contributor

@sonOfRa sonOfRa commented Nov 12, 2014

This allows users of the API to either specify a simple CA-File for certificate verification, or a custom SSLContext in order for a more fine-grained control of the TLS options they want to use.

As of now, no additional tests were added, but the existing tests were changed to reflect the changes in internal methods, so that they still pass.

I have some tests available, but they were designed for another monkeypatch around this, so I'll have to take some time to adjust them for this code before I can publish them.

This pull request also contains the test fix from #160.

@tarcieri
Copy link

👍

@@ -17,6 +17,8 @@ def initialize(server)
raise Net::LDAP::LdapError, "Server #{server[:host]} refused connection on port #{server[:port]}."
rescue Errno::EHOSTUNREACH => error
raise Net::LDAP::LdapError, "Host #{server[:host]} was unreachable (#{error.message})"
rescue Errno::ETIMEDOUT
raise Net::LDAP::LdapError, "Connection to #{server[:host]} timed out."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition, but could you file this in a separate PR? I'd like to keep this focused to the SSL changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, will do. Would you like a rebase, or a new commit that reverts this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not picky about pristine git history. Your choice ;)

This allows users of the API to either specify a simple CA-File for
certificate verification, or a custom SSLContext in order for a more
fine-grained control of the TLS options they want to use.

As of now, no additional tests were added, but the existing tests were
changed to reflect the changes in internal methods, so that they can
still pass
By default, we don't set any parameters (empty or no :tls_options). If
the hash is non-empty, we pass it directly to set_params and use the
resulting context for creating the TLS socket.
@jch jch self-assigned this Nov 13, 2014
@jch
Copy link
Member

jch commented Nov 13, 2014

Looking good.

I wish we had integration tests setup around SSL, but that's outside the scope of this PR. If anyone's looking for a side project, the OpenLDAP integration test README would be a good starting point. cc @mtodd

@tarcieri
Copy link

@jch I've actually written integration tests for TLS verification in an internal library using ruby-ldapserver. It's fairly easy to do:

https://github.com/inscitiv/ruby-ldapserver

@jch
Copy link
Member

jch commented Nov 13, 2014

@tarcieri neat. While it'd be convenient to have a ruby test server, I'm not interested in adding that as one of the integration test targets because it is not a common production server (correct me if I'm wrong).

I don't think it would be hard to have TLS integration tests in this projects. The steps, roughly, would be:

@tarcieri
Copy link

@jch for the purposes of testing verification of TLS certs, you don't even need an LDAP server, you could just as easily use a minimal TCP server w\ OpenSSL::SSL::SSLServer

@jch
Copy link
Member

jch commented Nov 13, 2014

you could just as easily use a minimal TCP server w\ OpenSSL::SSL::SSLServer

I trust ruby's stdlib implementations, so I'm not interested in standalone testing of TLS cert verification. The integration test with OpenLDAP (and other servers) would be more of a sanity check to make sure we don't release something incompatible with those specific servers.

@tarcieri
Copy link

Aah, I see. As a user of OpenLDAP, I agree that would be cool 😉

jch added a commit that referenced this pull request Nov 26, 2014
Implement custom tls options
@jch jch merged commit 2e3e77b into ruby-ldap:master Nov 26, 2014
@jch jch mentioned this pull request Dec 17, 2014
astratto pushed a commit to astratto/ruby-net-ldap that referenced this pull request Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants