Set X509 public key in 1.0.2

Thomas Dwyer III tomiii at tomiii.com
Fri Aug 20 23:19:31 UTC 2021


1.0.2 has X509_PUBKEY_get() (without the zero) which I believe increases
the reference count on the EVP_PKEY.


Tom.III


On Fri, Aug 20, 2021 at 3:31 PM Ken Goldman <kgoldman at us.ibm.com> wrote:

> I have an X509_PUBKEY structure holding the algorithm and public key.
> I want to set it in the X509 structure.
>
> In 1.1.1 and up, I can use
>
>         evpPubkey = X509_PUBKEY_get0(addToCert->key);   /* X509_PUBKEY */
>         X509_set_pubkey(x509Certificate, evpPubkey);
>
> However, 1.0.2 doesn't have these.
>
> What's a good approach?
>
> I could access the X509.cert_info.key and set the
> value, but I expect that would cause a double free later
> when I free both the X509 and the structure holding the
> X509_PUBKEY.
>
> Is the something like a X509_PUBKEY_dup function?
>
> (Yes, I know that 1.0.2 is obsolete, but there are some LTS
> distros, and I'd rather not drop support for 1.0.2 if I can
> figure this out.)
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mta.openssl.org/pipermail/openssl-users/attachments/20210820/7dce18a7/attachment.html>


More information about the openssl-users mailing list