473,569 Members | 2,593 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("ope nssl 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 17233
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("ope nssl 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
8985
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 really need help with are the first three and the last three statements. How would I rewrite those under Oracle to make sure they have the same...
1
8875
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 Windows 2003 Server and I cannot run the script from an ASP. No error is generated on the screen or in the event log. I think this has something to do...
0
1175
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 possibility to save locally. Now I have to save at a DBMS server (with DB2DAS00 running). Is this an error or is it a "work as designed" ?
3
2173
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. What do you think? Thank you! John
0
2733
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), Computer B (the remote computer).
0
1400
by: sambasiva | last post by:
hi, i have one .csv file and one server.my requirement is csv file server abc_gw.pdf abc_fillable.pdf xyz_gw.pdf ...
1
4788
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. Winzip is not an option. I tried to make a simple batch script that just moves the database into a compressed(zipped) folder and the .zip file...
1
2473
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 the name abd_Week 38. Every time the batch script runs the week no has to get incremnted by 1. Could you please help me with this.
5
5891
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 PERL Script. I want to return the values of the these two variables to the windows batch script. Can i do this? Please give me some suggestions. ...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
938
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.