<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Unfortunately, the short answer is I can't avoid the problem. The application is complicated, and can be thought of as many applications, all of which have different needs. I don't think combining a certificate chain into one file eliminates the need for all
 of the calls I'm making, just some of them. I wish it were that easy, but I need to do this set up at run time.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'll see what I can find, and try a few other things to attempt to isolate the cause. If I run out of ideas, I'll probably start a new thread since it may get more attention. </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks for your answers once again.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Jason</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> openssl-users <openssl-users-bounces@openssl.org> on behalf of Viktor Dukhovni <openssl-users@dukhovni.org><br>
<b>Sent:</b> Wednesday, November 3, 2021 9:25 PM<br>
<b>To:</b> openssl-users@openssl.org <openssl-users@openssl.org><br>
<b>Subject:</b> Re: X509_get_pubkey() in OpenSSL 3.0?</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">On Wed, Nov 03, 2021 at 08:32:43PM +0000, Jason Schultz wrote:<br>
<br>
> To summarize, at application start time I read in all of the<br>
> certificates in /etc/ssl/certs/ to a trusted store created with<br>
> X509_STORE_new().<br>
> <br>
> When getting ready to "start" a server (again, leaving a lot of<br>
> specifics out to avoid getting bogged down in details), I'm doing the<br>
> processing in the previous messages on this thread. Here are the API<br>
> calls again, with the changes previously discussed:<br>
> <br>
>     ctx = SSL_CTX_new_ex(non_fips_libctx, NULL, TLS_method());<br>
>     SSL_CTX_use_PrivateKey_file(ctx,<keyfile>,SSL_FILETYPE_PEM);<br>
>     SSL_CTX_use_certificate_file(ctx,<certfile>,SSL_FILETYPE_PEM);<br>
>     SSL_CTX_check_private_key(ctx);<br>
>     mycert = SSL_CTX_get0_certificate(ctx);<br>
>     pkey = X509_get_pubkey(mycert);<br>
> <br>
>  After that's done, I make several OpenSSL calls to get things set up the way I want:<br>
> <br>
>         param = X509_VERIFY_PARAM_new();<br>
>         X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_PARTIAL_CHAIN);<br>
>         X509_STORE_set1_param(ssl_trusted_certs, param);<br>
>         X509_VERIFY_PARAM_free(param);<br>
> <br>
> I call these to treat intermediate certs as trust-anchors, so I can<br>
> trust an intermediate certificate; ssl_trusted_certs is the<br>
> aforementioned X509_STORE.<br>
<br>
I am puzzled as to you working so hard (writing a bunch of low-level<br>
trust-store and chain construction code) to construct at runtime, what<br>
could be created statically at chain file construction time.  Especially<br>
if you stick with best practice and keep certificate lifetimes<br>
reasonably short (~90 days or less, not years).  The certificate chain<br>
file constructed at the time the certificate is issued should work<br>
unchanged for the lifetime of the certificate, and the server<br>
applications can avoid having to execute any chain construction or<br>
verification code.<br>
<br>
Yes, you're asking somewhat "interesting" questions, in that, e.g., I am<br>
not up to speed on all the changes in 3.0.0, and perhaps there are<br>
indeed some issues around legacy SHA1 signatures, but I do suspect that<br>
a more productive use of your time is likely to reconsider the decision<br>
to work at such a low layer.  It may be wiser to find a way to "unask"<br>
the question, i.e. make it moot, by avoiding rather than solving the<br>
problem.<br>
<br>
> I'm not clear on if the calls I've added to<br>
> SSL_CTX_get0_certificate(ctx) and X509_get_pubkey(), the latter of<br>
> which was being used before, are what's causing the problem. The<br>
> OpenSSL error queue shows the following on the<br>
> SSL_CTX_build_cert_chain() failure:<br>
> <br>
> 00B741558E7F0000:error:0308010C:digital envelope routines:(unknown function):unsupported:crypto/evp/evp_fetch.c:346:Global default library context, Algorithm (SHA1 : 96), Properties (<null>)<br>
> 00B741558E7F0000:error:03000072:digital envelope routines:(unknown function):decode error:crypto/x509/x_pubkey.c:444:<br>
> 00B741558E7F0000:error:03000072:digital envelope routines:(unknown function):decode error:crypto/x509/x_pubkey.c:444:<br>
> 00B741558E7F0000:error:0580006C:x509 certificate routines:(unknown function):unable to get certs public key:crypto/x509/x509_vfy.c:1986:<br>
> 00B741558E7F0000:error:0A000086:SSL routines:(unknown function):certificate verify failed:ssl/ssl_cert.c:905:Verify error:unspecified certificate verification error<br>
<br>
I haven't seen these before, your guess is as good as mine.<br>
<br>
-- <br>
    Viktor.<br>
</div>
</span></font></div>
</div>
</body>
</html>