I am trying to come up with regex that matches the value of "Key Container", but only if the issuer is CN=My_root_CA and the certificate is Non-root Certificate All of the above should be fulfil to match the certificate uniquely, because there are several similar certificates
================ Certificate 3 ================
Serial Number: 5471f66c066334ab48285398b0f24b7e
Issuer: CN=My_Root_CA, O=Experian, OU=Hunter, L=Sofia, S=CA, C=BG
NotBefore: 20/09/2016 15:48
NotAfter: 20/09/2024 15:48
Subject: CN=192.168.127.107
Non-root Certificate
Cert Hash(sha1): 46 92 41 60 56 36 32 fa bb 82 f2 45 0b 80 37 c4 28 15 e4 ca
Key Container = 52668461-19b4-4fef-80d6-5982ff702c3b
Unique container name: 0893f8f220ed765fabe249818ff664b9_bba0a089-1c2b-49c8-9f49-e4b211a91a55
Provider = Microsoft Strong Cryptographic Provider
Encryption test passed
I have tried this CN=My_Root_CA((.|
)*?)Non-root Certificate((.|
)*?)Key Container =(.*\b)
But this do not matches correctly if we have
================ Certificate 1 ================
Serial Number: b4b81124ff17b6af4eb18053cd9fecd5
Issuer: CN=My_Root_CA, O=Experian, OU=Hunter, L=Sofia, S=CA, C=BG
NotBefore: 20/09/2016 15:48
NotAfter: 20/09/2024 15:48
Subject: CN=My_Root_CA, O=Experian, OU=Hunter, L=Sofia, S=CA, C=BG
Signature matches Public Key
Root Certificate: Subject matches Issuer
Cert Hash(sha1): 8c 47 dd 5a 74 47 3a 74 e1 2a c4 de 6f 95 35 04 f6 2d d4 8a
Key Container = 25ea8612-7fd3-4504-97f8-d9150e6bfd63
Unique container name: 4e3f7aa1fb469fd4cb7b184d188059be_bba0a089-1c2b-49c8-9f49-e4b211a91a55
Provider = Microsoft Strong Cryptographic Provider
Encryption test passed
================ Certificate 2 ================
Serial Number: XXXXXXXX
Issuer: CN=TEST TEST FIND Root
NotBefore: 18/08/2015 16:16
NotAfter: 18/09/2017 16:26
Subject: CN=TEST CA
CA Version: V9.0
Certificate Template Name (Certificate Type): SubCA
Non-root Certificate
Template: SubCA
Cert Hash(sha1): 55 1b 22 8c c9 eb 25 58 25 3f 00 67 a3 6e 68 b1 62 43 de 75
No key provider information
Cannot find the certificate and private key for decryption.
Encryption test passed
================ Certificate 3 ================
Serial Number: 5471f66c066334ab48285398b0f24b7e
Issuer: CN=My_Root_CA, O=Experian, OU=Hunter, L=Sofia, S=CA, C=BG
NotBefore: 20/09/2016 15:48
NotAfter: 20/09/2024 15:48
Subject: CN=192.168.127.107
Non-root Certificate
Cert Hash(sha1): 46 92 41 60 56 36 32 fa bb 82 f2 45 0b 80 37 c4 28 15 e4 ca
Key Container = 52668461-19b4-4fef-80d6-5982ff702c3b
Unique container name: 0893f8f220ed765fabe249818ff664b9_bba0a089-1c2b-49c8-9f49-e4b211a91a55
Provider = Microsoft Strong Cryptographic Provider
Encryption test passed