245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'lib/redis/connection/ruby.rb', line 245
def self.connect(host, port, timeout, ssl_params)
tcp_sock = TCPSocket.connect(host, port, timeout)
ctx = OpenSSL::SSL::SSLContext.new
ctx.set_params(ssl_params || {})
ssl_sock = new(tcp_sock, ctx)
ssl_sock.hostname = host
begin
ssl_sock.connect_nonblock
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
if ssl_sock.wait_readable(timeout)
retry
else
raise TimeoutError
end
rescue IO::WaitWritable
if ssl_sock.wait_writable(timeout)
retry
else
raise TimeoutError
end
end
unless ctx.verify_mode == OpenSSL::SSL::VERIFY_NONE || (
ctx.respond_to?(:verify_hostname) &&
!ctx.verify_hostname
)
ssl_sock.post_connection_check(host)
end
ssl_sock
end
|