On Sat, Apr 10, 2010, Julien Kauffmann wrote:

> Hello,
>
> I need to extract the RSA public key from a RSA private key using OpenSSL.
>
> I'm currently using |RSAPublicKey_dup()| passing the |RSA*| private key to 
> get the public key. However, while the call seems to work, I cannot load 
> (or use) this public key using the openssl command-line tool.
>
> If I generate the public key using the command-line tool ("|$ openssl rsa 
> -in private.pem -pubout > public.pem|"), I can use it and it works like a 
> charm.
>
> Do you guys know how I can get this work ? Maybe another function ?
>
> Thank you.
>
> P.S: Here is the command line result when I try to use the generated public 
> key:
>
> u...@computer:~$ openssl rsa -text -pubin -in public.pem -noout
> unable to load Public Key
> 4379:error:0906D06C:PEM routines:PEM_read_bio:no start 
> line:pem_lib.c:647:Expecting: PUBLIC KEY
>

Use the functions with RSA_PUBKEY in the name to write out the key and not
RSAPublicKey.

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to