<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);">
Changing the subject to be more relevant to my questions. Just wanted to ping the list again.</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 Jason Schultz <jetson23@hotmail.com><br>
<b>Sent:</b> Friday, March 20, 2020 3:21 PM<br>
<b>To:</b> openssl-users@openssl.org <openssl-users@openssl.org><br>
<b>Subject:</b> Re: OpenSSL server sending certificate chain(inc. root cert) during handshake</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
I apologize for bringing this old subject back up, but I'm running into something I wanted to poll the list on.</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<br>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
Based on Victor's email below, I am doing the following in my application to set up my server to send a certificate chain *excluding* the root certificate during a handshake.</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<br>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<span style="margin:0px">status = SSL_CTX_set_mode(ctx, SSL_MODE_NO_AUTO_CHAIN);<br>
</span><span style="margin:0px">status = SSL_CTX_build_cert_chain(ctx, SSL_BUILD_CHAIN_FLAG_NO_ROOT);</span></div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<span style="margin:0px"><br>
</span></div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
When I configure a certificate chain, the server sends the chain, excluding the root. The call to SSL_CTX_build_cert_chain() accomplishes this, with the "no root" flag. This works as expected.</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<br>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
The interesting part comes in when I am configuring a self-signed certificate as the server cert.</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<br>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
** NOTE **: I know this isn't recommended, this is ONLY for test purposes, and our users will configure servers in this way, also ONLY for test purposes. This is why I'm testing the operation of this configuration.</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<br>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
As Victor indicated, my EE certificate is also the entire chain; of 1 self-signed certificate. Setting the SSL_MODE_AUTO_CHAIN flag allowed me to configure a self-signed certificate on the server, the two calls above succeed, and my server sends that single,
 self-signed cert in the handshake. This is true for version 3 self-signed certificates, with the CA bit set.</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<br>
</div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
If I have a version 1 *RSA* certificate, with the CA bit NOT set(so CA:FALSE), the call to <span style="margin:0px; background-color:rgb(255,255,255); display:inline!important">SSL_CTX_build_cert_chain() errors. I think this is the expected behavior. Does everyone
 agree with that? Since OpenSSL 1.1.1 is more strict regarding the CA bit, the building of the "chain" will fail because a self-signed cert MUST have CA:TRUE.</span></div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<span style="margin:0px; background-color:rgb(255,255,255); display:inline!important"><br>
</span></div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<span style="margin:0px; background-color:rgb(255,255,255); display:inline!important">The incorrect behavior I think I'm seeing is when configuring a self-signed ECDSA certificate. I'll paste the certificate below, but I would think this version 1 certificate
 that does NOT have CA:TRUE would error in the same was the similar RSA certificate did above. Does anyone know what could be the result of the (seemingly) different behavior? Are there any other tests I could try to lead me to an answer?</span></div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<span style="margin:0px; background-color:rgb(255,255,255); display:inline!important"><br>
</span></div>
<div style="margin:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255)">
<span style="margin:0px; background-color:rgb(255,255,255); display:inline!important">Thanks,</span></div>
<br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span>Jason</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span>TEST:/etc/ssl # openssl x509 -text -noout -in certs/ecdsacert.pem<br>
</span>
<div>Certificate:<br>
</div>
<div>    Data:<br>
</div>
<div>        Version: 1 (0x0)<br>
</div>
<div>        Serial Number:<br>
</div>
<div>            de:6e:db:59:3a:03:e5:ac<br>
</div>
<div>    Signature Algorithm: ecdsa-with-SHA256<br>
</div>
<div>        Issuer: C=US, ST=State, L=City, O=Company, OU=Networking, CN=COMMON-NAME/emailAddress=john.doe@example.com<br>
</div>
<div>        Validity<br>
</div>
<div>            Not Before: Mar 17 18:23:09 2020 GMT<br>
</div>
<div>            Not After : Mar 17 18:23:09 2021 GMT<br>
</div>
<div>        Subject: C=US, ST=<span style="font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255); display:inline!important">State</span>, L=<span style="font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255); display:inline!important">City</span>,
 O=<span style="font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255); display:inline!important">Company</span>, OU=Networking, CN=<span style="font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255); display:inline!important">COMMON</span>-<span style="font-family:Calibri,Helvetica,sans-serif; background-color:rgb(255,255,255); display:inline!important">NAME</span>/emailAddress=john.doe@example.com<br>
</div>
<div>        Subject Public Key Info:<br>
</div>
<div>            Public Key Algorithm: id-ecPublicKey<br>
</div>
<div>                Public-Key: (256 bit)<br>
</div>
<div>                pub:<br>
</div>
<div>                    04:dc:67:d3:f5:53:0b:c9:3c:13:e9:d9:52:17:60:<br>
</div>
<div>                    fb:a2:f6:ad:98:74:a4:1b:6d:57:52:81:d3:e5:8f:<br>
</div>
<div>                    e9:0f:a6:32:81:8f:f6:6d:3f:f2:1c:1c:6b:a7:c6:<br>
</div>
<div>                    3a:59:a3:c8:ce:12:08:ee:5c:8c:3e:4f:52:cb:35:<br>
</div>
<div>                    dc:6b:1a:de:59<br>
</div>
<div>                ASN1 OID: prime256v1<br>
</div>
<div>                NIST CURVE: P-256<br>
</div>
<div>    Signature Algorithm: ecdsa-with-SHA256<br>
</div>
<div>         30:45:02:20:66:d8:35:06:98:38:0a:88:57:c4:8d:30:02:97:<br>
</div>
<div>         3a:e7:4f:34:4a:50:d2:5c:e7:16:61:80:b3:43:41:7f:71:42:<br>
</div>
<div>         02:21:00:82:c2:39:b5:52:d4:e9:aa:21:d5:d1:fb:e8:01:e2:<br>
</div>
<div>         aa:81:16:75:cb:0d:2c:33:f6:34:5b:54:80:ac:82:66:4f<br>
</div>
<div><br>
</div>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div>
<div id="x_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="x_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> Friday, May 31, 2019 9:44 PM<br>
<b>To:</b> openssl-users@openssl.org <openssl-users@openssl.org><br>
<b>Subject:</b> Re: OpenSSL server sending certificate chain(inc. root cert) during handshake</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">> On May 31, 2019, at 3:20 PM, Jason Schultz <jetson23@hotmail.com> wrote:<br>
> <br>
> My questions deal with #2: Why does OpenSSL include the root cert in the certificate chain?<br>
<br>
The OpenSSL SSL_CTX_build_cert_chain(3) function constructs a complete<br>
chain of trust for your certificate chain, based on the configured trust<br>
stores (CAfile and/or CApath).  If you call this function, then you can<br>
control how your certificates chain is augmented.<br>
<br>
But if your EE certificate is the entire chain, then the internal automatic<br>
chain construction code will assume that the chain was not built, and will<br>
try to augment it unless you set the SSL_MODE_NO_AUTO_CHAIN flag via:<br>
<br>
  SSL_CTX_set_mode(3), or<br>
  SSL_set_mode(3)<br>
<br>
[ Which really ought to also document SSL_MODE_NO_AUTO_CHAIN ]<br>
<br>
> Will the root cert be included in the chain any time it's in the same directory<br>
> as the server cert?<br>
<br>
No, the chain is augmented based on the configured trust stores, and does<br>
not directly consider the directory holding the chain file.<br>
<br>
> Is there a way, via API call, configuration, etc, to force OpenSSL to NOT send the<br>
> root certificate as part of the chain in this case?<br>
<br>
You can set a CAfile/CApath that do not include the location of the root<br>
cert, or disable automatic chain construction, and build the chain just<br>
the way you like it via SSL_CTX_build_cert_chain(3), possibly passing the<br>
SSL_BUILD_CHAIN_FLAG_NO_ROOT flag.<br>
<br>
-- <br>
        Viktor.<br>
<br>
</div>
</span></font></div>
</div>
</div>
</div>
</body>
</html>