jruby-openssl icon indicating copy to clipboard operation
jruby-openssl copied to clipboard

Intercept reads/writes to underlying TCPSocket

Open ertygiq opened this issue 4 years ago • 0 comments

Is there a way to intercept reads and writes SSLSocket does into underlying TCPSocket? I tried the following way, but overridden methods were not invoked:

class TCPSocket
    def write(*args)
        p "write"
        super *args
    end
    def read(*args)
        p "read"
        super *args
    end
end

Tcp_socket = TCPSocket.open '127.0.0.1', 80
ssl_context = OpenSSL::SSL::SSLContext.new
socket = OpenSSL::SSL::SSLSocket.new(Tcp_socket, ssl_context)
socket.connect

ertygiq avatar Sep 09 '21 08:09 ertygiq