Class | Mongo::SSLSocket |
In: |
lib/mongo/util/ssl_socket.rb
|
Parent: | Object |
A basic wrapper over Ruby‘s SSLSocket that initiates a TCP connection over SSL and then provides an basic interface mirroring Ruby‘s TCPSocket, vis., TCPSocket#send and TCPSocket#read.
# File lib/mongo/util/ssl_socket.rb, line 10 def initialize(host, port) @socket = ::TCPSocket.new(host, port) @ssl = OpenSSL::SSL::SSLSocket.new(@socket) @ssl.sync_close = true @ssl.connect end
# File lib/mongo/util/ssl_socket.rb, line 29 def read(length, buffer) @ssl.sysread(length, buffer) end