Skip to content

Commit 839c50f

Browse files
committed
Work around broken sync_close in OpenSSL::SSL::SSLSocket
ssl_ber_spec showed failures on Ruby 1.9.3, 2.0.0 and 2.1.1 (OS X and Linux) which could only be resolved by manually closing the underlying connection. Changing the test to use a TCP socket did not help, so it seems to be a bug in the SSLSocket class.
1 parent 0c439a9 commit 839c50f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/net/ldap.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,14 +1160,24 @@ def getbyte
11601160
end
11611161
end
11621162

1163+
module FixSSLSocketSyncClose
1164+
def close
1165+
super
1166+
io.close
1167+
end
1168+
end
1169+
11631170
def self.wrap_with_ssl(io)
11641171
raise Net::LDAP::LdapError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
11651172
ctx = OpenSSL::SSL::SSLContext.new
11661173
conn = OpenSSL::SSL::SSLSocket.new(io, ctx)
11671174
conn.connect
1168-
conn.sync_close = true
1175+
1176+
# Doesn't work:
1177+
# conn.sync_close = true
11691178

11701179
conn.extend(GetbyteForSSLSocket) unless conn.respond_to?(:getbyte)
1180+
conn.extend(FixSSLSocketSyncClose)
11711181

11721182
conn
11731183
end

0 commit comments

Comments
 (0)