Hi all,

I am attempting to import a RSA Public Key file generated by JRE 5.0 using 
OpenSSL.

As I understand it, JRE's RSA Public Key is in X.509's SubjectPublicKeyInfo 
structure.   I saved the byte array returned by JRE's RSAPublicKey.getEncoded() 
into a file.

Now I like to import this byte array into a C program using OpenSSL.  I am 
using Ubuntu 6.06 (i386) with OpenSSL version 0.9.8a 11 Oct 2005.

>From reading through /usr/include/openssl/x509.h, I tried to use these two 
>functions:

d2i_RSAPublicKey() and  d2i_RSAPublicKey_fp() functions.

I tried to use d2i_RSAPublicKey_fp() first, here is a snippet:

FILE* keyFilePtr = fopen("keyfile.dat", "rb");
...
RSA* rsaKeyPtr = d2i_RSAPublicKey_fp(keyFilePtr, NULL);

Now, when I check `rsaKeyPtr` it is NULL.  So I used ERR_error_string_n() to 
show the error message and this is what I got:

error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error

The same thing happens when I store the content of the JRE RSA PublicKey file 
into an array of unsigned char and then used d2i_RSAPublicKey().

Any ideas?  Has anyone done something like this successfully before?

My ultimate aim is to import JRE RSA Public Key from a server over a network.

Thanks.

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

Reply via email to