Extract Subject details from certificate in Batch script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dosuser97625
Posts: 1
Joined: 02 Jul 2019 04:51

Extract Subject details from certificate in Batch script

#1 Post by dosuser97625 » 02 Jul 2019 05:03

Hi,
I am using below command to get Subject information:
CertUtil -dump test.cer
I am getting full certificate info.

But I need to get below Subject details and use in batch script
Subject:
CN=test.co.uk
OU=test
O=test
L=test
S=test
C=GB

Can someone please help me to get only this info to make use in batch script.

-Dosuser

penpen
Expert
Posts: 1713
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Extract Subject details from certificate in Batch script

#2 Post by penpen » 08 Jul 2019 11:23

I'm unsire if you could use a "for/f"-loop to extract that information (depends on the exact the output of your comnmand).
Could you provide a sample output (with alienated data)?

penpen

Post Reply