Forum Discussion

swapnil1's avatar
swapnil1
Icon for Nimbostratus rankNimbostratus
May 23, 2019

How to grep particular certificate name or common name from list of all certificates?

I am looking for a tmsh command which can give me the ability to grep (search) particular common name or subset of common name in all certificate list.

4 Replies

  • This should work to return the common name in the subject. You may want to experiment with line numbers before to display the cert name too

    tmsh list sys file ssl-cert | grep my-common-name
  • MehulT's avatar
    MehulT
    Icon for Nimbostratus rankNimbostratus

    You can also try to get all the related information on that particular certificate

    tmsh list sys file ssl-cert one-line | grep my-common-name
  • Seyler's avatar
    Seyler
    Icon for Nimbostratus rankNimbostratus

    The awk snippet works for extracting the different parts, but you still need to know which section is the key / cert / chain. I needed to extract a specific section, and found this on the OpenSSL mailinglist.

  • If you have certs on partitions other than 'Common' use the following from bash:

    tmsh list sys file ssl-cert '/*/*' one-line | grep my-common-name

    If you want to just output the file name do the following:

    tmsh list sys file ssl-cert '/*/*' one-line | grep my-common-name | awk '{print $4}'