@@ -539,7 +539,7 @@ def initialize(args = {})
539539 @auth = args [ :auth ] || DefaultAuth
540540 @base = args [ :base ] || DefaultTreebase
541541 @force_no_page = args [ :force_no_page ] || DefaultForceNoPage
542- @encryption = args [ :encryption ] # may be nil
542+ @encryption = normalize_encryption ( args [ :encryption ] ) # may be nil
543543 @connect_timeout = args [ :connect_timeout ]
544544
545545 if pr = @auth [ :password ] and pr . respond_to? ( :call )
@@ -609,13 +609,7 @@ def authenticate(username, password)
609609 def encryption ( args )
610610 warn "Deprecation warning: please give :encryption option as a Hash to Net::LDAP.new"
611611 return if args . nil?
612- return @encryption = args if args . is_a? Hash
613-
614- case method = args . to_sym
615- when :simple_tls , :start_tls
616- args = { :method => method , :tls_options => { } }
617- end
618- @encryption = args
612+ @encryption = normalize_encryption ( args )
619613 end
620614
621615 # #open takes the same parameters as #new. #open makes a network
@@ -1323,4 +1317,17 @@ def new_connection
13231317 }
13241318 raise e
13251319 end
1320+
1321+ # Normalize encryption parameter the constructor accepts, expands a few
1322+ # convenience symbols into recognizable hashes
1323+ def normalize_encryption ( args )
1324+ return if args . nil?
1325+ return args if args . is_a? Hash
1326+
1327+ case method = args . to_sym
1328+ when :simple_tls , :start_tls
1329+ { :method => method , :tls_options => { } }
1330+ end
1331+ end
1332+
13261333end # class LDAP
0 commit comments