How to terminate an openssl handshake from a batch file?

I have written a PHP program to execute a batch file which contains openssl commands:

openssl s_client -showcerts -connect google.com:443 >test.cert

Taking the output of this batch file ie test.cert, I run another batch file which has these commands :

openssl x509 -noout -in test.cert -dates >date.txt
openssl x509 -noout -in test.cert -issuer >issuer.txt

But the problem is that the first batch file does not terminate because the cmd is waiting for handshake completion. So, the second batch file does not run. How do I terminate the first batch file?

Upvotes: 2

Views: 4717

Answers (2)

Bill
Bill

Reputation: 1

> echo 'x' |  openssl s_client -showcert -connect google.com:443 > test.cert

Upvotes: 0

dwalter
dwalter

Reputation: 7468

openssl s_client waits for input so you have to terminate the connection not the handshake. the easiest way would be to change

 openssl s_client -showcert -connect google.com:443 > test.cert

to

 openssl s_client -showcert -connect google.com:443 < /dev/null > test.cert

this should close the connection right after it was established.

Upvotes: 7

Related Questions