Many thanks all who responded
Andy
Jiri Holinek wrote:
> > I am trying to load a private key in DER format using
> > RSA_usePrivateKeyFile without success.
> I use this technique for load private key from file.
>
> unsigned char Buffer[2048], *a;
> i/* 2048 is enough to store 1024 bit key */
> nt len;
> RSA *rsa = NULL;
> FILE *fp;
>
> fp = fopen("privkey.der", "rb");
> if (fp == NULL)
> exit(1);
> len = fread(Buffer, sizeof(Buffer)-1, sizeof(unsigned char), fp);
> fclose(fp);
> a = Buffer; /* ATTENTION: pointer a is moved with next function*/
> rsa = d2i_RSAPrivateKey(NULL, &a, len);
> if (rsa == NULL)
> {
> ERR_print_errors_fp(stderr);
> exit(1);
> }
> > Is there a utility or segment of code somewhere that I can use to
> > convert the DER format to PEM format as that seems to work fine.
>
> fp = fopen("privkey.pem","w");
> if (fp == NULL)
> exit(1);
> result = PEM_write_RSAPrivateKey(fp, rsa, NULL, NULL, 0, NULL,
> NULL);
> /* If you want to store PrivateKey encrypted you can use
>
> result = PEM_write_RSAPrivateKey(fp, rsa,
> EVP_bf_cfb(), // cipher to use for encrypt
>key
> (unsigned char *)"some password", // your password
> strlen("some password"),
> NULL, NULL);
> */
> if (result <= 0)
> {
> ERR_print_errors_fp(stderr);
> exit(1);
> }
>
> That's all
>
> -------------------------------
> ing. Jiri Holinek
> CD s.o. DATIS o.z.
> U Tiskarny 3
> 702 00 Ostrava
> Czech Republic
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> Development Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
begin:vcard
n:Griffin;Andrew
tel;home:0018 9722935
tel;work:0118 9245580
x-mozilla-html:FALSE
org:<IMG SRC=http://www.freenetpages.co.uk/hp/griffina/Sawicon.gif>
adr:;;;;;;
version:2.1
email;internet:[EMAIL PROTECTED]
note:IMAP://ims1.uk.oracle.com?fetch>UID>/Personal>183&part=1.2
x-mozilla-cpt:;-6704
fn:Andrew Griffin
end:vcard