<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Windows scripted input using output from splunk openssl command? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232551#M45368</link>
    <description>&lt;P&gt;Interesting!  Glad you got it sorted.  &lt;/P&gt;

&lt;P&gt;For future reference, I checked a bit more and the key was to run the cmd prompt in Administrator mode.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Users\MyUser&amp;gt;"C:\program files\SplunkUniversalForwarder\bin\splunk" cmd openssl x509 -enddate -noout -in "C:\program files\SplunkUniversalForwarder\etc\auth\ca.pem" &amp;gt;output.txt

C:\Users\MyUser&amp;gt;type output.txt
notAfter=May  8 19:51:37 2025 GMT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which matches what I get when I run yours&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Users\MyUser&amp;gt;"C:\Program Files\SplunkUniversalForwarder\bin\openssl" x509 -enddate -noout -in "C:\Program Files\SplunkUniversalForwarder\etc\auth\cacert.pem" &amp;gt;cacert.txt
WARNING: can't open config file: C:\\wrangler-2.0\\build-home\\ember/ssl/openssl.cnf

C:\Users\MyUser&amp;gt;type output.txt
notAfter=May  8 19:51:37 2025 GMT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Actually, you'll notice when I run it not as a Splunk cmd there's something missing in the config settings (probably an environment variable), causing a WARNING to be spit out on STDERR.  You could capture that too, because though CMD isn't quite as robust of fully featured as even sh, it DOES support a lot of stuff folks don't know about.  The key there is to redirect to a file, then tell CMD to redirect stderr (2) to the same place as stdoutput (1), with this tagged on the end: &lt;CODE&gt;2&amp;gt;&amp;amp;1&lt;/CODE&gt;, like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Users\MyUser&amp;gt;"C:\Program Files\SplunkUniversalForwarder\bin\openssl" x509 -enddate -noout -in "C:\Program Files\SplunkUniversalForwarder\etc\auth\cacert.pem" &amp;gt;cacert.txt 2&amp;gt;&amp;amp;1

C:\Users\MyUser&amp;gt;type cacert.txt
notAfter=May  8 19:51:37 2025 GMT
WARNING: can't open config file: C:\\wrangler-2.0\\build-home\\ember/ssl/openssl.cnf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of course, you probably do NOT actually want to save that warning output.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 07 May 2016 02:10:29 GMT</pubDate>
    <dc:creator>Richfez</dc:creator>
    <dc:date>2016-05-07T02:10:29Z</dc:date>
    <item>
      <title>Windows scripted input using output from splunk openssl command?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232547#M45364</link>
      <description>&lt;P&gt;Does anyone have a nice windows scripted input that will output the local certificate end date?&lt;/P&gt;

&lt;P&gt;ie. something like &lt;/P&gt;

&lt;P&gt;inputs.conf&lt;BR /&gt;
[script://.\bin\ssl_check.bat]&lt;BR /&gt;
disabled = false&lt;BR /&gt;
index = ssl_check&lt;BR /&gt;
interval = -1&lt;BR /&gt;
sourcetype = ssl_check&lt;/P&gt;

&lt;P&gt;ssl_check.bat&lt;BR /&gt;
"C:\program files\SplunkUniversalForwarder\bin\splunk" cmd openssl x509 -enddate -noout -in "C:\program files\SplunkUniversalForwarder\etc\auth\ca.pem"&lt;/P&gt;

&lt;P&gt;My problem is that the windows openssl opens its own little window and doesn't output to stdout. As such there isn't any text for the input to grab.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/127203-splunk-openssl-console-output.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;edit: i've tried numerous x509 parameters but nothing seens to want to output a text version of the certificate to a file. All the -out or -text options only output to the spawned console which can't be grabbed.&lt;/P&gt;

&lt;P&gt;We need this to verify remediation work.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:36:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232547#M45364</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2020-09-29T09:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Windows scripted input using output from splunk openssl command?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232548#M45365</link>
      <description>&lt;P&gt;Have you tried a simple &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;blah my command &amp;gt; outputfilename.txt
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should redirect the entire pile of output to a text file called outputfilename.txt.&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 00:09:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232548#M45365</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-05-06T00:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Windows scripted input using output from splunk openssl command?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232549#M45366</link>
      <description>&lt;P&gt;Its not a unix box. Its windows.&lt;/P&gt;

&lt;P&gt;Please try what your suggesting on a windows machine and seeing what happens. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 05:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232549#M45366</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2016-05-06T05:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Windows scripted input using output from splunk openssl command?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232550#M45367</link>
      <description>&lt;P&gt;I've figured out a way to do it by calling the binary directly and not the "splunk cmd"  method.&lt;/P&gt;

&lt;P&gt;Below is my scripted input &lt;/P&gt;

&lt;P&gt;inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script://.\bin\ssl_check_ca.bat]
disabled = false
index = sos
interval = 86400
sourcetype = ssl_check_ca
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;ssl_check_ca.bat&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)
"C:\Program Files\SplunkUniversalForwarder\bin\openssl" x509 -enddate -noout -in "C:\Program Files\SplunkUniversalForwarder\etc\auth\cacert.pem" &amp;gt;cacert.txt
set /p VV=&amp;lt;cacert.txt
For /f "tokens=1-6 delims=/ " %%a in ('echo %VV%') do (set enddate=%%a="%%b %%c %%d %%e %%f")
echo %mydate% %mytime%, ssl_cert=cacert.pem, %enddate%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It is a start and provides a nice mostly clean output like the following which is good enough for what it needs to do.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-06-05 03:19 PM, ssl_cert=cacert.pem, notAfter="Jul 21 17:12:19 2016 GMT"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: this doesn't do ANY path validation so it just assumes a default installation directory.&lt;BR /&gt;
This has only been run on windows 10 so I still need to validate it against other versions of windows.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:36:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232550#M45367</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2020-09-29T09:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Windows scripted input using output from splunk openssl command?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232551#M45368</link>
      <description>&lt;P&gt;Interesting!  Glad you got it sorted.  &lt;/P&gt;

&lt;P&gt;For future reference, I checked a bit more and the key was to run the cmd prompt in Administrator mode.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Users\MyUser&amp;gt;"C:\program files\SplunkUniversalForwarder\bin\splunk" cmd openssl x509 -enddate -noout -in "C:\program files\SplunkUniversalForwarder\etc\auth\ca.pem" &amp;gt;output.txt

C:\Users\MyUser&amp;gt;type output.txt
notAfter=May  8 19:51:37 2025 GMT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which matches what I get when I run yours&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Users\MyUser&amp;gt;"C:\Program Files\SplunkUniversalForwarder\bin\openssl" x509 -enddate -noout -in "C:\Program Files\SplunkUniversalForwarder\etc\auth\cacert.pem" &amp;gt;cacert.txt
WARNING: can't open config file: C:\\wrangler-2.0\\build-home\\ember/ssl/openssl.cnf

C:\Users\MyUser&amp;gt;type output.txt
notAfter=May  8 19:51:37 2025 GMT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Actually, you'll notice when I run it not as a Splunk cmd there's something missing in the config settings (probably an environment variable), causing a WARNING to be spit out on STDERR.  You could capture that too, because though CMD isn't quite as robust of fully featured as even sh, it DOES support a lot of stuff folks don't know about.  The key there is to redirect to a file, then tell CMD to redirect stderr (2) to the same place as stdoutput (1), with this tagged on the end: &lt;CODE&gt;2&amp;gt;&amp;amp;1&lt;/CODE&gt;, like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;C:\Users\MyUser&amp;gt;"C:\Program Files\SplunkUniversalForwarder\bin\openssl" x509 -enddate -noout -in "C:\Program Files\SplunkUniversalForwarder\etc\auth\cacert.pem" &amp;gt;cacert.txt 2&amp;gt;&amp;amp;1

C:\Users\MyUser&amp;gt;type cacert.txt
notAfter=May  8 19:51:37 2025 GMT
WARNING: can't open config file: C:\\wrangler-2.0\\build-home\\ember/ssl/openssl.cnf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Of course, you probably do NOT actually want to save that warning output.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2016 02:10:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232551#M45368</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-05-07T02:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Windows scripted input using output from splunk openssl command?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232552#M45369</link>
      <description>&lt;P&gt;Thanks. yeah on the machines I tried it on i couldn't get the splunk cmd openssl output to redirect to a file using the "&amp;gt;". Not sure if it was a windows 10 issue. Directly calling the openssl was the way that it worked in the end.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 23:26:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Windows-scripted-input-using-output-from-splunk-openssl-command/m-p/232552#M45369</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2016-05-10T23:26:07Z</dc:date>
    </item>
  </channel>
</rss>

