Simple SSL client hangs

Loris Bennett loris.bennett at fu-berlin.de
Tue Jul 13 03:50:19 EDT 2021


Hi,

In Perl I have the following

  use IO::Socket::SSL;

  my $my_socket = new IO::Socket::SSL(PeerAddr => 'some.server.somewhere,
  				      PeerPort => 12345,
  				     );

  my $line = <$my_socket>;
  print("$line\n");
  say $my_socket 'ECHO 1';
  $line = <$my_socket>;
  print("$line\n");

This runs as expected and I get

  200 Some Server Somewhere - Hello [123.456.789.123]

  310 Hello Echo

If I try the same with the following Python code:

  import socket
  import ssl

  HOST = "some.server.somewhere"
  PORT = 12345

  context = ssl.create_default_context()

  with socket.create_connection((HOST, PORT)) as sock:
      with context.wrap_socket(sock, server_hostname=HOST) as ssock:
          data = ssock.recv(1024)
          print(data.decode())
          ssock.write(b'ECHO 1')
          data = ssock.read(1024)
          print(data.decode())

I get a timeout for the 'ECHO' command:

  200 Some Server Somewhere - Hello [123.456.789.123]

  501 Timeout

Does anyone have an idea what I might be doing wrong?

Cheers,

Loris

-- 
This signature is currently under construction.


More information about the Python-list mailing list