<div dir="ltr"><div>1.0.2 has X509_PUBKEY_get() (without the zero) which I believe increases the reference count on the EVP_PKEY.</div><div><br></div><div><br></div><div>Tom.III</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 20, 2021 at 3:31 PM Ken Goldman <<a href="mailto:kgoldman@us.ibm.com">kgoldman@us.ibm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I have an X509_PUBKEY structure holding the algorithm and public key.<br>
I want to set it in the X509 structure.<br>
<br>
In 1.1.1 and up, I can use<br>
<br>
        evpPubkey = X509_PUBKEY_get0(addToCert->key);   /* X509_PUBKEY */<br>
        X509_set_pubkey(x509Certificate, evpPubkey);<br>
<br>
However, 1.0.2 doesn't have these.<br>
<br>
What's a good approach?<br>
<br>
I could access the X509.cert_info.key and set the<br>
value, but I expect that would cause a double free later<br>
when I free both the X509 and the structure holding the<br>
X509_PUBKEY.<br>
<br>
Is the something like a X509_PUBKEY_dup function?<br>
<br>
(Yes, I know that 1.0.2 is obsolete, but there are some LTS<br>
distros, and I'd rather not drop support for 1.0.2 if I can<br>
figure this out.)<br>
<br>
<br>
</blockquote></div>