in reply to Re^2: IO::Socket:SSL and Net::Server STDOUT redirection
in thread IO::Socket:SSL and Net::Server STDOUT redirection

Hi Zucan,

sorry, but I have to admit I'm an idiot. While testing several options being curious, I did exactly the same as you:

print $client "The client should see this message.\n";

I left this line unchanged while changing others and was happy to "having found the solution".

Sorry again.

But with using openssl s_client I found out that sending the message via STDOUT seemed to circumvent the encryption layer. This lead me to the conclusion that you have to redirect some "upper" layer.

UPDATE: Being aschamed about my error I gave it another try. I now did a:

*STDOUT = $client;

I really hope this also works for you now.

Regards
McA

Replies are listed 'Best First'.
Re^4: IO::Socket:SSL and Net::Server STDOUT redirection
by Zucan (Beadle) on Nov 17, 2014 at 21:23 UTC

    Ah, that worked!

    Here is the working example:
    #!/usr/bin/perl -w use strict; use IO::Socket::SSL; my $port = 12345; my $server = IO::Socket::SSL->new( LocalAddr => '127.0.0.1', LocalPort => $port, Listen => 10, Reuse => 1, SSL_cert_file => 'cert.pem', SSL_key_file => 'key.pem', ) or die "failed to listen: $!"; my $client = $server->accept; *STDOUT = $client; print "The client should see this STDOUT message.\n"; print $client "The client should see this SOCKET message.\n"; close($client);
    The output I now see is as follows:
    $ nc --ssl localhost 12345 The client should see this STDOUT message. The client should see this SOCKET message.
    Thank you!