GeezerVison is showing github.com — Clear certificate chain in setKeyMaterial (#985). · netty/netty-tcnative@0ce2e0a
File tree
Expand file treeCollapse file tree
Open diff view settings
openssl-dynamic/src/main/c
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: openssl-dynamic/src/main/c/ssl.c +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2316,6 +2316,19 @@ TCN_IMPLEMENT_CALL(void, SSL, setKeyMaterial)(TCN_STDARGS, jlong ssl, jlong chai |
2316 | 2316 | } |
2317 | 2317 | } |
2318 | 2318 |
|
| 2319 | + // Clear the chain; the loop below appends certificates to the |
| 2320 | + // chain, and in TLS 1.3, this can be called again after the |
| 2321 | + // server sends a HelloRetryRequest. Without clearing the |
| 2322 | + // certificate chain that results in duplicate entries. |
| 2323 | + if (tcn_SSL_clear_chain_certs(ssl_) != 1) { |
| 2324 | + ERR_error_string(ERR_get_error(), err, ERR_LEN); |
| 2325 | + ERR_clear_error(); |
| 2326 | + |
| 2327 | + tcn_Throw(e, "Could not clear certificate chain (%s)", err); |
| 2328 | + return; |
| 2329 | + } |
| 2330 | + |
| 2331 | + |
2319 | 2332 | // The first cert was loaded via SSL_use_certificate so skip it. |
2320 | 2333 | for (i = 1; i < numCerts; ++i) { |
2321 | 2334 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: openssl-dynamic/src/main/c/ssl_private.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -473,6 +473,7 @@ enum ssl_verify_result_t tcn_SSL_cert_custom_verify(SSL* ssl, uint8_t *out_alert |
473 | 473 | #if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) |
474 | 474 | #define tcn_SSL_add1_chain_cert(ssl, x509) SSL_add1_chain_cert(ssl, x509) |
475 | 475 | #define tcn_SSL_add0_chain_cert(ssl, x509) SSL_add0_chain_cert(ssl, x509) |
| 476 | +#define tcn_SSL_clear_chain_certs(ssl) SSL_clear_chain_certs(ssl) |
476 | 477 | #endif // !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC) |
477 | 478 |
|
478 | 479 | #define tcn_SSL_get0_certificate_types(ssl, clist) SSL_get0_certificate_types(ssl, clist) |
|