GnuWin32 openssl s_client conn to WebSphere MQ server not closing at EOF, hangs

后端 未结 1 2031
无人共我
无人共我 2020-12-10 09:26

I am trying to use the GnuWin32 version of OpenSSL to fetch certificates from several WebSphere MQ queue managers. All attempts result in OpenSSL keeping the connection ope

1条回答
  •  Happy的楠姐
    2020-12-10 09:59

    It seems that this problem is related to a synchronization issue between the Batch file and the openssl.exe program. I need your collaboration in order to do some tests and report the result. Below is a Batch-JScript hybrid script for the first test. The JScript section have two parts; the first one WScript.Stdout.WriteLine("QUIT"); is entirely equivalent to echo QUIT Batch command. The second part (with two lines) is similar, but it load the keyboard buffer with "QUIT" and an Enter key instead of send the string via STDOUT.

    I need you to make a test with both sections of the JScript code and report the result (the double-slash // mark the rest of the line as comment). If we are lucky, the openssl.exe program will end with the Sendkeys method; if not, try to send a "QUIT" string via STDOUT and type just an Enter key with Sendkeys. If the openssl.exe program terminate before returning the desired information then the problem is almost solved, because in this case we can synchronize the sending of the Enter key until the desired information had been received from openssl.exe.

    Save the following as a .bat file. Try it, then comment out the Wscript line, uncomment the WshShell lines, and then try it again.

    @if (@CodeSection == @Batch) @then
    
    :: The first line above is...
    :: in Batch: a valid IF command that does nothing.
    :: in JScript: a conditional compilation IF statemente that is false,
    ::             so this section is omitted until next "at-sign end".
    
    @echo off
    CScript //nologo //E:JScript "%~F0" | openssl s_client -connect qmgrhost:1414 -showcerts 
    goto :EOF
    
    
    @end
    
    
    // JScript section
    
    WScript.Stdout.WriteLine("QUIT");
    
    // var WshShell = WScript.CreateObject("WScript.Shell");
    // WshShell.SendKeys("QUIT{ENTER}");
    

    You may also try with String.fromCharCode(26) to generate a Ctrl-Z (EOF) character, both in WriteLine or Sendkeys methods; for example:

    WshShell.SendKeys("QUIT{ENTER}" + String.fromCharCode(26));
    

    0 讨论(0)
提交回复
热议问题