>       From: owner-openssl-us...@openssl.org On Behalf Of Aravind GJ
>       Sent: Tuesday, 22 November, 2011 23:32

>       I use BIO_new_mem_buf and PEM_read_bio_X509 to convert 
> the certificate in memory buffer to X509 certificate format. 
> Finally the certificate is then added to the CA store.

>       If the buffer contains certificate chain like <snip>
>       Only the first certificate is then read. Is there 
> a way to handle the appended CA's?

Works for me. Check your code, or see (simplified) attachment.
Make sure all your BEGIN/END lines are correct and in particular
you don't have one --END-- and next --BEGIN-- on same line.

#include <openssl/pem.h>

int main (void) {
        char allcerts [99999]; int n = fread (allcerts,1,sizeof allcerts,stdin);
        BIO *mem = BIO_new_mem_buf(allcerts,n), *out = BIO_new_fp(stdout,0);
        X509 *x;
        printf ("%d\n", n);
        while( (x = PEM_read_bio_X509 (mem, NULL, NULL, NULL)) != NULL ){
                X509_NAME_print (out, X509_get_subject_name(x), 0);
                BIO_puts (out, "\n");
        }
        return 0;
}

Reply via email to