How to extract Certificate info from file with multible certificates?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to extract Certificate info from file with multible certificates?

alindber (Bugzilla)
I have a certificate file CAcert.pem containing two or more certificates between BEGIN/END blocks.

the openssl command only seems to read the first certificate.

How can I extract information from all certs in a single file?

It would be nice to do something like:

     openssl x509 -noout -in CAcert.pem -date -all 

to extract the start/end dates for all certs.

Thanks for your help with this.
Alex Lindberg
Reply | Threaded
Open this post in threaded view
|

Re: How to extract Certificate info from file with multible certificates?

Victor Duchovni
On Fri, Jul 22, 2011 at 02:03:27PM -0700, Alex Lindberg wrote:

> I have a certificate file CAcert.pem containing two or more certificates between BEGIN/END blocks.
>
> the openssl command only seems to read the first certificate.
>
> How can I extract information from all certs in a single file?

    $ openssl crl2pkcs7 -nocrl -certfile certs.pem |
        openssl pkcs7 -print_certs -text |
        pcregrep '^\s+(?:Not (?:Before|After)|Issuer|Subject)\s*:'

--
        Viktor.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to extract Certificate info from file with multible certificates?

alindber (Bugzilla)
Thanks.

--- On Fri, 7/22/11, Victor Duchovni <[hidden email]> wrote:

From: Victor Duchovni <[hidden email]>
Subject: Re: How to extract Certificate info from file with multible certificates?
To: [hidden email]
Date: Friday, July 22, 2011, 4:15 PM

On Fri, Jul 22, 2011 at 02:03:27PM -0700, Alex Lindberg wrote:

> I have a certificate file CAcert.pem containing two or more certificates between BEGIN/END blocks.
>
> the openssl command only seems to read the first certificate.
>
> How can I extract information from all certs in a single file?

    $ openssl crl2pkcs7 -nocrl -certfile certs.pem |
    openssl pkcs7 -print_certs -text |
    pcregrep '^\s+(?:Not (?:Before|After)|Issuer|Subject)\s*:'

--
    Viktor.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@...
Automated List Manager                           majordomo@...