Hello.

   I'm trying to validate a X509 certificate using the code below. I tried 
several certificates, some generated by openssl and some generated by other 
CAs. In all cases I receive the same error (erro code # 7, which is defined 
as X509_V_ERR_CERT_SIGNATURE_FAILURE).

   I know the certificates are valid (as they are accepted by other CAs) 
and thus, I'd like to know if anyone can help me finding what is wrong in 
the code below. Any help will be greatly appreciated.

------------------------------ cut here --------------------------------------
#include <stdio.h>
#include "pem.h"

void main(void)
{
         X509_STORE              *ctx=NULL;
         X509_STORE_CTX  csc;
         X509                    *x509;
         FILE                    *rfp;
         int                     i, j;


         rfp = fopen("test.crt","r");
         x509 = PEM_read_X509(rfp,NULL,NULL,NULL);
         fclose(rfp);
         ctx=X509_STORE_new();
         X509_STORE_set_default_paths(ctx);
         X509_STORE_CTX_init(&csc,ctx,x509,NULL);
         i=X509_verify_cert(&csc);
         j=X509_STORE_CTX_get_error(&csc);
         if (i) printf("OK\n");
      else printf("Error %d\n",j);
      X509_STORE_CTX_cleanup(&csc);
}
---------------------------------- cut here 
---------------------------------------

Thanks in advance

Gustavo



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to