> If you have a private key in an RSA structure and just want
> to write out
> the public components then you can use
> PEM_write_RSAPublicKey() and read
> it in with PEM_read_RSAPublicKey(). The key read back will then just
> contain the RSA public key components and naturally can't be used for
> private key operations.
>
> The "EXPECTING PUBLIC KEY" message is telling you what the PEM routine
> is expecting to see in the BEGIN and END lines of the PEM
> file. If your
> file doesn't have BEGIN PUBLIC KEY (as it wont) then you'll get the
> error.
Would it be possible to use the i2d_RSAPublicKey(...) code the RSA
public key to DER and write the result out to a binary file?
After that, d2i_RSAPrivateKey(...) could be used to restore the RSA
structure. I have never done that.
Kind regards,
Armin
