Is there a way that i can get an X509 cert from an array holding a cert in
DER format.
I know to read PEM format cert you got to do the following.
static X509 *loadCertFromMem(char *pCert, int pLength)
{
STACK_OF(X509_INFO) *sk = NULL;
X509 *returnCert = NULL;
BIO *bin = NULL;
if (!(sk = sk_X509_new_null())) {
printf("getCert: sk_X509_new_null memory allocation failure\n");
goto end;
}
bin = BIO_new_mem_buf(pCert, pLength);
printf("build the bio\n");
if (!(sk = PEM_X509_INFO_read_bio(bin, NULL, NULL, NULL)))
{
printf("getCert:error reading from BIO\n");
goto end;
}
//printf("%s \n", pCert);
while(sk_X509_INFO_num(sk))
{
X509_INFO *info = sk_X509_INFO_shift(sk);
printf("inside while \n");
if (info->x509 != NULL)
{
printf("x509 not null \n");
returnCert = malloc(sizeof(X509));
returnCert = memcpy(returnCert, info->x509, sizeof(X509));
info->x509 = NULL;
X509_INFO_free(info);
break;
}
}
end:
BIO_set_close(bin, BIO_NOCLOSE);
BIO_free(bin);
sk_X509_INFO_free(sk);
return(returnCert);
}
So my question is How do i read a DER using a BIO cause the cert in is
memory and not in a file (for file i know there are d2i functions that
return X509).
Thanks
KB
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]