I'm trying to implement a TCP socket via stunnel but not sure how to capture the server response. My stunnel configuration file is exactly like this:
[Coinbase]
client = yes
accept = 127.0.0.1:4197
connect = fix.gdax.com:4198
verify = 4
CAfile = /etc/fix.gdax.com.pem
And the Python code I have is:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 4197))
msg = b'GET / HTTP/1.1\nHost: www.google.com\n\n' # ping google as a means of testing
s.send(msg)
print(s.recv(1024))
Whatever the message I send over the socket (including those that the server located at fix.gdax.com would expect) the result of that print statement is always just an empty string in byte form:
b''
The stunnel log is as follows:
2017.11.02 20:49:58 LOG5[7]: Service [Coinbase] accepted connection from
127.0.0.1:65205
2017.11.02 20:49:58 LOG5[7]: s_connect: connected 52.86.60.82:4198
2017.11.02 20:49:58 LOG5[7]: Service [Coinbase] connected remote server from
192.168.0.14:65206
2017.11.02 20:49:58 LOG5[7]: Certificate accepted at depth=0: C=US,
ST=California, L=San Francisco, O="Coinbase, Inc.", CN=*.gdax.com
2017.11.02 20:50:06 LOG3[7]: readsocket: Connection reset by peer
(WSAECONNRESET) (10054)
2017.11.02 20:50:06 LOG5[7]: Connection reset: 37 byte(s) sent to TLS, 0
byte(s) sent to socket
My interpretation of that is that the message is going out fine and the certificate is valid etc, but I can't work out how to receive data sent back by the server... any help greatly appreciated! I'm quite new to TCP & SSL so apologies if any of the terminology is wrong.