<?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: How to create a regex to extract fields in a certificate? in Splunk Enterprise Security</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303562#M2705</link>
    <description>&lt;P&gt;I just found out regex101 lets you save tests!&lt;BR /&gt;
partially working:&lt;BR /&gt;
&lt;A href="https://regex101.com/r/ZOyEIg/1"&gt;https://regex101.com/r/ZOyEIg/1&lt;/A&gt;&lt;BR /&gt;
and @elliotproebstel working version&lt;BR /&gt;
&lt;A href="https://regex101.com/r/ZOyEIg/2"&gt;https://regex101.com/r/ZOyEIg/2&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 19:22:58 GMT</pubDate>
    <dc:creator>kchamplin_splun</dc:creator>
    <dc:date>2018-04-04T19:22:58Z</dc:date>
    <item>
      <title>How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303557#M2700</link>
      <description>&lt;P&gt;I need to extract various fields if they exist.  CN, C, S, O, OU,  Here is a sample data of five different events.  Please note that this is a snippet of each event and not the entire event.  I left in the ssl_issuer in the first event but removed the string in the last four events.   One challenge is there are duplicate field names in ssl_issurer and ssl_subject.  I have tried various regex expressions but they either get too much or too little out of the events.  I would like to have one regex for each field in the transforms.conf, that way I don't have the whole thing fail if there is a problem in the data.&lt;/P&gt;

&lt;P&gt;This fairly close, but skips the second and fourth event. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ssl_subject\="CN=(.*)C=(.*)S=(.*)O=(.*)OU=(.*)ssl_start_time

ssl_issuer="CN=DigiCert SHA2 High Assurance Server CA C=US O=DigiCert Inc OU=www.digicert.com" ssl_hash="f41565b049f039e765a0f8be8271a4b4817b7378" ssl_subject="CN=syndication.twitter.com C=US S=California O=Twitter, Inc. OU=Twitter Security" ssl_start_time="Wed Jun 29 00:00:00 2016 UTC" ssl_end_time="Mon Sep 16 12:00:00 2019 UTC" ssl_type="X.509 Certificate" ssl_extended_key_usage="Server Authentication, Client Authentication" ssl_key_length="2048 bits" ssl_key_usage="Digital Signature, Key Encipherment"

ssl_subject="CN=*.eu-west-1.webrootcloudav.com" ssl_start_time="Tue Aug 22 00:00:00 2017 UTC" ssl_end_time="Sat Sep 22 12:00:00 2018 UTC" ssl_type="X.509 Certificate" ssl_extended_key_usage="" ssl_key_length="2048 bits" ssl_key_usage="Digital Signature, Non-Repudiation, Key Encipherment"

ssl_subject="CN=*.us.static.hrsmart.com C=US S=Virginia O=Deltek, Inc. OU=Security Services" ssl_start_time="Thu Jan 11 00:00:00 2018 UTC" ssl_end_time="Sun Mar 31 12:00:00 2019 UTC" ssl_type="X.509 Certificate" ssl_extended_key_usage="Server Authentication, Client Authentication" ssl_key_length="2048 bits" ssl_key_usage="Digital Signature, Key Encipherment"

ssl_subject="CN=*.googleapis.com C=US S=California O=Google Inc" ssl_start_time="Tue Mar 13 18:57:10 2018 UTC" ssl_end_time="Tue Jun  5 18:17:00 2018 UTC" ssl_type="X.509 Certificate" ssl_extended_key_usage="Server Authentication, Client Authentication" ssl_key_length="0 bits" ssl_key_usage="Digital Signature, Certificate Signing, CRL Signing"

ssl_subject="CN=subscription.rhsm.redhat.com C=US S=North Carolina O=Red Hat, Inc. OU=Red Hat Network" ssl_start_time="Thu May 18 16:30:24 2017 UTC" ssl_end_time="Sat May 18 16:30:24 2019 UTC" ssl_type="X.509 Certificate" ssl_extended_key_usage="Server Authentication" ssl_key_length="4096 bits" ssl_key_usage=""
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:46:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303557#M2700</guid>
      <dc:creator>regriffith</dc:creator>
      <dc:date>2020-09-29T18:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303558#M2701</link>
      <description>&lt;P&gt;See if this gets you a bit closer:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;("|\s)(?&amp;lt;key&amp;gt;(CN|C|O|OU))=(?&amp;lt;value&amp;gt;(\w|\s|\d|\.)+)(\s|")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:34:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303558#M2701</guid>
      <dc:creator>kchamplin_splun</dc:creator>
      <dc:date>2018-04-04T17:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303559#M2702</link>
      <description>&lt;P&gt;It is different that what I have tried.  This gets tripped up by ssl_issuer.  In some cases the result doesn't include country code and other data.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 18:10:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303559#M2702</guid>
      <dc:creator>regriffith</dc:creator>
      <dc:date>2018-04-04T18:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303560#M2703</link>
      <description>&lt;P&gt;You're totally right, I did't check my work closely enough - there's a few things on the capture group for the O,OU,S, etc that are easy to fix - let me see if I can work out something for the other items.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 18:20:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303560#M2703</guid>
      <dc:creator>kchamplin_splun</dc:creator>
      <dc:date>2018-04-04T18:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303561#M2704</link>
      <description>&lt;P&gt;Here's a revision that I think should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;("|\s)(?&amp;lt;key&amp;gt;(CN|C|O|OU|S))=(?&amp;lt;value&amp;gt;[^=\"]+)(?=(\s|"))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 19:15:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303561#M2704</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-04-04T19:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303562#M2705</link>
      <description>&lt;P&gt;I just found out regex101 lets you save tests!&lt;BR /&gt;
partially working:&lt;BR /&gt;
&lt;A href="https://regex101.com/r/ZOyEIg/1"&gt;https://regex101.com/r/ZOyEIg/1&lt;/A&gt;&lt;BR /&gt;
and @elliotproebstel working version&lt;BR /&gt;
&lt;A href="https://regex101.com/r/ZOyEIg/2"&gt;https://regex101.com/r/ZOyEIg/2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 19:22:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303562#M2705</guid>
      <dc:creator>kchamplin_splun</dc:creator>
      <dc:date>2018-04-04T19:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303563#M2706</link>
      <description>&lt;P&gt;Much closer, but it is matching ssl_issuer= and  ssl_subject=.  It should only match  values in ssl_subject=&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:47:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303563#M2706</guid>
      <dc:creator>regriffith</dc:creator>
      <dc:date>2020-09-29T18:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303564#M2707</link>
      <description>&lt;P&gt;Ok, if you only want to match on values in events with &lt;CODE&gt;ssl_subject=&lt;/CODE&gt;, then this should do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ssl_subject\="(CN=(?&amp;lt;CN&amp;gt;[^=]*))?(C=(?&amp;lt;C&amp;gt;[^=]*))?(S=(?&amp;lt;S&amp;gt;[^=]*))?(O=(?&amp;lt;O&amp;gt;[^=]*))?(OU=(?&amp;lt;OU&amp;gt;[^=]*))?" ssl_start_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's a link to test: &lt;A href="https://regex101.com/r/ZOyEIg/3"&gt;https://regex101.com/r/ZOyEIg/3&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 15:01:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303564#M2707</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-04-05T15:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract fields in a certificate?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303565#M2708</link>
      <description>&lt;P&gt;Thanks for the information, it was a tremendous help.&lt;/P&gt;

&lt;P&gt;This is what I used for subject:&lt;BR /&gt;
&lt;CODE&gt;"ssl_subject\="(CN=(?&amp;lt;ssl_subject_common_name&amp;gt;[^=]*))?(C=(?&amp;lt;C&amp;gt;[^=]*))?(S=(?&amp;lt;ssl_subject_state&amp;gt;[^=]*))?(O=(?&amp;lt;ssl_subject_organization&amp;gt;[^=]*))?(OU=(?&amp;lt;ssl_subject_unit&amp;gt;[^=]*))?" ssl_start_time"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This is what I used for issuer:&lt;BR /&gt;
&lt;CODE&gt;ssl_issuer\="(CN=(?&amp;lt;ssl_issuer_common_name&amp;gt;[^=]*))?(C=(?&amp;lt;C&amp;gt;[^=]*))?(S=(?&amp;lt;ssl_issuer_state&amp;gt;[^=]*))?(O=(?&amp;lt;ssl_issuer_organization&amp;gt;[^=]*))?(OU=(?&amp;lt;ssl_issuer_unit&amp;gt;[^=]*))?" ssl_hash&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 18:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/How-to-create-a-regex-to-extract-fields-in-a-certificate/m-p/303565#M2708</guid>
      <dc:creator>regriffith</dc:creator>
      <dc:date>2019-05-30T18:12:31Z</dc:date>
    </item>
  </channel>
</rss>

