Arno,

You could use a memory bio. I had to do something like this when I stored
my keys PEM encoded into a gdbm database.

ie:

BIO *in;
char  *certificate = "----BEGIN CERT...."

in = BIO_new(BIO_s_mem());

if (BIO_write(certificate,strlen(certificate))<0) {
                BIO_free(in);
                return NULL;
}

then you can just do the following once the bio is setup.

X509 *cert = PEM_read_bio_X509(in,NULL,NULL,NULL);

see BIO_s_mem manpage, there is another way to do it where you can pass
the BIO the actual buffer, but I don't recall how.

The other option would be to use openssl x509 -C -in cert.pem to convert
the pem into a C variable. I'm not sure how to get it into an X509
structure from there though.

hope this helps,

-jr



Arno Puder wrote:

> Hi,
>
> certificates and private keys are usually stored in PEM-formatted files
> and are loaded using the functions SSL_CTX_use_certificate_file() and
> SSL_CTX_use_PrivateKey_file().
>
> If I want to hard code the keys in my application, such as
>
> char* certificate = "-----BEGIN CERTIFICATE-----"
> "MIIC1...";
>
> is there an API that I can use in this case to initialize the keys?
>
> Thx,
> Arno
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]

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

Reply via email to