473,503 Members | 544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

automate openssl s_client command in batch or PHP script

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
Jul 17 '05 #1
1 17202
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
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
8978
by: Jeff Lambert | last post by:
We have a Windows client application written in delphi that connects to Oracle 8i w/ ADO. We accumulate a lot of SQL statements in a loop and finally send the strings list to be executed. What I...
1
8844
by: Matt | last post by:
I used to execute a command line script in IIS 4 using Dynuexec. This is a third part server object I installed on the server (http://www.dynu.com/dynuexec.asp). I installed this object onto my...
0
1170
by: Kim Bundgaard | last post by:
Hi I've changed my DB2 client from V7 to V8 (fixpak 4). Previously I used Command Center/Script to save my scripts locally at my client, but after my change to V8, I do not have the...
3
2167
by: John McGinty | last post by:
simple as that really. I want to run a batch script when a button in pressed. The script is to run a DTS package (thats another issue entirely) to refresh some data which is all working just fine....
0
2722
by: py | last post by:
I am trying to execute a batch script on a remote computer. The batch script looks like: @echo off start c:\python24\python.exe c:\a_script.py Here's the setup: Computer A (my computer),...
0
1390
by: sambasiva | last post by:
hi, i have one .csv file and one server.my requirement is csv file server abc_gw.pdf ...
1
4782
by: jschmidt | last post by:
I am wondering if there is a way to zip a (one) file using a batch script. I have an access database that needs to be zipped on a regular basis because many people download this file from a website. ...
1
2467
by: Rajeswary | last post by:
I need to copy an excel doc in the same directory with a new name.. That is I have got an excel file abd_Week 37 and I need to run a batch script to copy the same file to the same directory with...
5
5871
by: veeraiah | last post by:
Hi, I am new to PERL Scripting, i need your help with one of the problem i am having. I am having a PERL Script which has two variables $CurMon and $PriorMon. a Windows batch script calls this...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.