iThunder has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am trying to script an openssl s_client command which is giving different results when put into script compare it when its run directly on the client. When i run following openssl s_client command on my linux client

openssl s_client -connect 1.1.1.90:443

I am prompted to enter input. When i copy/paste following

POST / HTTP/1.1

Host: example.com

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0)Gecko/20100101 Firefox/36.0

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate

I can see that every line is put into a different TLS/SSL record and sent to my server. But when i try to do the same using perl script, it is always sending all six lines into a single SSL record. Is there a way i can force it to send into separate records? Below is the script i am trying

#!/usr/bin/perl $| = 1; open($handle, "| openssl s_client -connect 1.1.1.90:443 -quiet"); open(file,"<","1.txt"); while (<file>){ print $handle $_,"\r\n";} close file; open(file,"<","2.txt"); while (<file>){ print $handle $_,"\r\n";} close file; open(file,"<","3.txt"); while (<file>){ print $handle $_,"\r\n";} close file; close $handle

Replies are listed 'Best First'.
Re: Openssl, ssl records and perl
by Corion (Patriarch) on Apr 12, 2016 at 07:07 UTC

    Maybe you can flush the filehandle. But IPC is a fickle thing and buffering can happen in the OS or in the child process without much recourse.