This is a discussion on automate openssl s_client command in batch or PHP script within the PHP Language forums, part of the PHP Programming Forums category; Hello, I want to retrieve the details of an SSL certificate of HTTPS websites, using openSSL, running on Windows 2003. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I want to retrieve the details of an SSL certificate of HTTPS websites, using openSSL, running on Windows 2003. This works fine as follows: openssl s_client www.somewebsite.com:443 > cert.txt In order to close the openSSL connection to the HTTPS website, I have to manually type "quit" + enter. Now I want to use this line in a PHP script (running on Windows 2003 with IIS6), so I do not have the possibility to type "quit" + enter. If I use following code, the PHP script will hang: shell_exec("openssl s_client www.somewebsite.com:443 > cert.txt") Is there a possibility to automate openSSL s_client, so it can be used from a script or batch ? I have tried to invoke the above openSSL command from VBS, and use sendkeys("quit{enter}"). This works fine if ran from a DOS window, but not if the VBS script in turn is invoked by a PHP webpage. In this case, the PHP page will wait for the VBS script to end, and because the VBS script is invoked from a PHP webpage and not in a DOS window, the sendkeys function doesn't work. So PHP will wait infinitely and hang. Can openSSL s_client be automated, or can one of the PHP functions shell_exec, or exec or popen be used without the script hanging infinitely ? Thanks for your help, Niko |
|
|||
|
Niko wrote:
> Hello, > > I want to retrieve the details of an SSL certificate of HTTPS > websites, using openSSL, running on Windows 2003. This works fine as > follows: > > openssl s_client www.somewebsite.com:443 > cert.txt > > In order to close the openSSL connection to the HTTPS website, I have > to manually type "quit" + enter. > > Now I want to use this line in a PHP script (running on Windows 2003 > with IIS6), so I do not have the possibility to type "quit" + enter. > If I use following code, the PHP script will hang: > > shell_exec("openssl s_client www.somewebsite.com:443 > cert.txt") > > Is there a possibility to automate openSSL s_client, so it can be used > from a script or batch ? You got many options. The simplest would be: "openssl s_client -connect xyz:443 < quit.txt > cert.txt" Where quit.txt contains "quit\n" /Bent |