@@ -476,61 +476,73 @@ def self.result2string(code) #:nodoc:
476476  #   specify a treebase. If you give a treebase value in any particular 
477477  #   call to #search, that value will override any treebase value you give 
478478  #   here. 
479+   # * :force_no_page => Set to true to prevent paged results even if your 
480+   #   server says it supports them. This is a fix for MS Active Directory 
481+   # * :instrumentation_service => An object responsible for instrumenting 
482+   #   operations, compatible with ActiveSupport::Notifications' public API. 
479483  # * :encryption => specifies the encryption to be used in communicating 
480484  #   with the LDAP server. The value must be a Hash containing additional 
481485  #   parameters, which consists of two keys: 
482486  #     method: - :simple_tls or :start_tls 
483-   #     options : - Hash of options for that method 
487+   #     tls_options : - Hash of options for that method 
484488  #   The :simple_tls encryption method encrypts <i>all</i> communications 
485489  #   with the LDAP server. It completely establishes SSL/TLS encryption with 
486490  #   the LDAP server before any LDAP-protocol data is exchanged. There is no 
487491  #   plaintext negotiation and no special encryption-request controls are 
488492  #   sent to the server. <i>The :simple_tls option is the simplest, easiest 
489493  #   way to encrypt communications between Net::LDAP and LDAP servers.</i> 
490-   #   It's intended for cases where you have an implicit level of trust in the 
491-   #   authenticity of the LDAP server. No validation of the LDAP server's SSL 
492-   #   certificate is performed. This means that :simple_tls will not produce 
493-   #   errors if the LDAP server's encryption certificate is not signed by a 
494-   #   well-known Certification Authority. If you get communications or 
495-   #   protocol errors when using this option, check with your LDAP server 
496-   #   administrator. Pay particular attention to the TCP port you are 
497-   #   connecting to. It's impossible for an LDAP server to support plaintext 
498-   #   LDAP communications and <i>simple TLS</i> connections on the same port. 
499-   #   The standard TCP port for unencrypted LDAP connections is 389, but the 
500-   #   standard port for simple-TLS encrypted connections is 636. Be sure you 
501-   #   are using the correct port. 
502-   # 
494+   #   If you get communications or protocol errors when using this option, 
495+   #   check with your LDAP server administrator. Pay particular attention 
496+   #   to the TCP port you are connecting to. It's impossible for an LDAP 
497+   #   server to support plaintext LDAP communications and <i>simple TLS</i> 
498+   #   connections on the same port. The standard TCP port for unencrypted 
499+   #   LDAP connections is 389, but the standard port for simple-TLS 
500+   #   encrypted connections is 636. Be sure you are using the correct port. 
503501  #   The :start_tls like the :simple_tls encryption method also encrypts all 
504502  #   communcations with the LDAP server. With the exception that it operates 
505503  #   over the standard TCP port. 
506504  # 
507-   #   In order to verify certificates and enable other TLS options, the 
508-   #   :tls_options hash can be passed alongside :simple_tls or :start_tls. 
509-   #   This hash contains any options that can be passed to 
510-   #   OpenSSL::SSL::SSLContext#set_params(). The most common options passed 
511-   #   should be OpenSSL::SSL::SSLContext::DEFAULT_PARAMS, or the :ca_file option, 
512-   #   which contains a path to a Certificate Authority file (PEM-encoded). 
513-   # 
514-   #   Example for a default setup without custom settings: 
515-   #     { 
516-   #       :method => :simple_tls, 
517-   #       :tls_options => OpenSSL::SSL::SSLContext::DEFAULT_PARAMS 
518-   #     } 
505+   #   To validate the LDAP server's certificate (a security must if you're 
506+   #   talking over the public internet), you need to set :tls_options 
507+   #   something like this... 
519508  # 
520-   #   Example for specifying a CA-File and only allowing TLSv1.1 connections:  
521-   # 
522-   #     { 
523-   #       : method => :start_tls , 
524-   #       : tls_options => { :ca_file => "/etc/cafile.pem", :ssl_version => "TLSv1_1" }  
509+   #   Net::LDAP.new(  
510+   #     # ... set host, bind dn, etc ...  
511+   #     encryption:  { 
512+   #       method: :simple_tls , 
513+   #       tls_options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS,  
525514  #     } 
526-   # * :force_no_page => Set to true to prevent paged results even if your 
527-   #   server says it supports them. This is a fix for MS Active Directory 
528-   # * :instrumentation_service => An object responsible for instrumenting 
529-   #   operations, compatible with ActiveSupport::Notifications' public API. 
515+   #   ) 
516+   # 
517+   #   The above will use the operating system-provided store of CA 
518+   #   certificates to validate your LDAP server's cert. 
519+   #   If cert validation fails, it'll happen during the #bind 
520+   #   whenever you first try to open a connection to the server. 
521+   #   Those methods will throw Net::LDAP::ConnectionError with 
522+   #   a message about certificate verify failing. If your 
523+   #   LDAP server's certificate is signed by DigiCert, Comodo, etc., 
524+   #   you're probably good. If you've got a self-signed cert but it's 
525+   #   been added to the host's OS-maintained CA store (e.g. on Debian 
526+   #   add foobar.crt to /usr/local/share/ca-certificates/ and run 
527+   #   `update-ca-certificates`), then the cert should pass validation. 
528+   #   To ignore the OS's CA store, put your CA in a PEM-encoded file and... 
529+   # 
530+   #   encryption: { 
531+   #     method:      :simple_tls, 
532+   #     tls_options: { ca_file:     '/path/to/my-little-ca.pem', 
533+   #                    ssl_version: 'TLSv1_1' }, 
534+   #   } 
535+   # 
536+   #   As you might guess, the above example also fails the connection 
537+   #   if the client can't negotiate TLS v1.1. 
538+   #   tls_options is ultimately passed to OpenSSL::SSL::SSLContext#set_params 
539+   #   For more details, see 
540+   #    http://ruby-doc.org/stdlib-2.0.0/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html 
530541  # 
531542  # Instantiating a Net::LDAP object does <i>not</i> result in network 
532543  # traffic to the LDAP server. It simply stores the connection and binding 
533-   # parameters in the object. 
544+   # parameters in the object. That's why Net::LDAP.new doesn't throw 
545+   # cert validation errors itself; #bind does instead. 
534546  def  initialize ( args  =  { } ) 
535547    @host  =  args [ :host ]  || DefaultHost 
536548    @port  =  args [ :port ]  || DefaultPort 
0 commit comments