net-ldap 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of net-ldap might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.rdoc +4 -0
- data/lib/net/ldap/connection.rb +29 -9
- data/lib/net/ldap/version.rb +1 -1
- data/test/test_ldap_connection.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26f8c374bc1cc4a9c355ae968cf1ca29d1efc335
|
4
|
+
data.tar.gz: 2bd1fc2b1ef9bd5939200a06ba9ce4bf24ae85de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d7caa7c7800648300d1cfb52dc09d54dd7df4eb39f2ed88e9f8fcdf8cb8119a4e6582541dfe4ebcca69739cd7166366621a2f76dd974fd7f370796a7c4fe14c
|
7
|
+
data.tar.gz: 71856da21d5c8387cc25f9364d27c43cc48300bd7dd7213b6b35f5a3de42509479d9682f51bc8d894ddd36c21ff5cc0c04e034b051f376b4ab9f17518a249581
|
data/History.rdoc
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
=== Net::LDAP 0.15.0
|
2
|
+
|
3
|
+
* Respect connect_timeout when establishing SSL connections {#273}[https://github.com/ruby-ldap/ruby-net-ldap/pull/273]
|
4
|
+
|
1
5
|
=== Net::LDAP 0.14.0
|
2
6
|
|
3
7
|
* Normalize the encryption parameter passed to the LDAP constructor {#264}[https://github.com/ruby-ldap/ruby-net-ldap/pull/264]
|
data/lib/net/ldap/connection.rb
CHANGED
@@ -31,26 +31,27 @@ class Net::LDAP::Connection #:nodoc:
|
|
31
31
|
@socket_class = socket_class
|
32
32
|
end
|
33
33
|
|
34
|
-
def prepare_socket(server)
|
34
|
+
def prepare_socket(server, timeout=nil)
|
35
35
|
socket = server[:socket]
|
36
36
|
encryption = server[:encryption]
|
37
37
|
|
38
38
|
@conn = socket
|
39
|
-
setup_encryption
|
39
|
+
setup_encryption(encryption, timeout) if encryption
|
40
40
|
end
|
41
41
|
|
42
42
|
def open_connection(server)
|
43
43
|
hosts = server[:hosts]
|
44
44
|
encryption = server[:encryption]
|
45
45
|
|
46
|
+
timeout = server[:connect_timeout] || DefaultConnectTimeout
|
46
47
|
socket_opts = {
|
47
|
-
connect_timeout:
|
48
|
+
connect_timeout: timeout,
|
48
49
|
}
|
49
50
|
|
50
51
|
errors = []
|
51
52
|
hosts.each do |host, port|
|
52
53
|
begin
|
53
|
-
prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)))
|
54
|
+
prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)), timeout)
|
54
55
|
return
|
55
56
|
rescue Net::LDAP::Error, SocketError, SystemCallError,
|
56
57
|
OpenSSL::SSL::SSLError => e
|
@@ -76,7 +77,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
def self.wrap_with_ssl(io, tls_options = {})
|
80
|
+
def self.wrap_with_ssl(io, tls_options = {}, timeout=nil)
|
80
81
|
raise Net::LDAP::NoOpenSSLError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
|
81
82
|
|
82
83
|
ctx = OpenSSL::SSL::SSLContext.new
|
@@ -86,7 +87,26 @@ class Net::LDAP::Connection #:nodoc:
|
|
86
87
|
ctx.set_params(tls_options) unless tls_options.empty?
|
87
88
|
|
88
89
|
conn = OpenSSL::SSL::SSLSocket.new(io, ctx)
|
89
|
-
|
90
|
+
|
91
|
+
begin
|
92
|
+
if timeout
|
93
|
+
conn.connect_nonblock
|
94
|
+
else
|
95
|
+
conn.connect
|
96
|
+
end
|
97
|
+
rescue IO::WaitReadable
|
98
|
+
if IO.select([conn], nil, nil, timeout)
|
99
|
+
retry
|
100
|
+
else
|
101
|
+
raise Errno::ETIMEDOUT, "OpenSSL connection read timeout"
|
102
|
+
end
|
103
|
+
rescue IO::WaitWritable
|
104
|
+
if IO.select(nil, [conn], nil, timeout)
|
105
|
+
retry
|
106
|
+
else
|
107
|
+
raise Errno::ETIMEDOUT, "OpenSSL connection write timeout"
|
108
|
+
end
|
109
|
+
end
|
90
110
|
|
91
111
|
# Doesn't work:
|
92
112
|
# conn.sync_close = true
|
@@ -123,11 +143,11 @@ class Net::LDAP::Connection #:nodoc:
|
|
123
143
|
# communications, as with simple_tls. Thanks for Kouhei Sutou for
|
124
144
|
# generously contributing the :start_tls path.
|
125
145
|
#++
|
126
|
-
def setup_encryption(args)
|
146
|
+
def setup_encryption(args, timeout=nil)
|
127
147
|
args[:tls_options] ||= {}
|
128
148
|
case args[:method]
|
129
149
|
when :simple_tls
|
130
|
-
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options])
|
150
|
+
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout)
|
131
151
|
# additional branches requiring server validation and peer certs, etc.
|
132
152
|
# go here.
|
133
153
|
when :start_tls
|
@@ -144,7 +164,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
144
164
|
end
|
145
165
|
|
146
166
|
if pdu.result_code.zero?
|
147
|
-
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options])
|
167
|
+
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout)
|
148
168
|
else
|
149
169
|
raise Net::LDAP::StartTLSError, "start_tls failed: #{pdu.result_code}"
|
150
170
|
end
|
data/lib/net/ldap/version.rb
CHANGED
@@ -291,7 +291,7 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
291
291
|
and_return(result2)
|
292
292
|
mock.should_receive(:write)
|
293
293
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
294
|
-
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}).
|
294
|
+
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil).
|
295
295
|
and_return(mock)
|
296
296
|
|
297
297
|
conn.next_msgid # simulates ongoing query
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Cianfrocca
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2016-
|
16
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: flexmock
|