Add SSL_use_cert_and_key for per-connection cert/key setting#3114
Add SSL_use_cert_and_key for per-connection cert/key setting#3114
Conversation
Postgres recently started calling SSL_use_cert_and_key (the per-SSL variant) which AWS-LC did not implement. This broke the postgres integration test on both x86_64 and aarch64 with an undefined reference linker error. Extract the body of SSL_CTX_use_cert_and_key into a static helper cert_use_cert_and_key(CERT *) and add SSL_use_cert_and_key as a thin wrapper, following the established pattern used by SSL_use_PrivateKey, ssl_set_cert, and cert_set_chain_and_key.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3114 +/- ##
==========================================
+ Coverage 78.20% 78.38% +0.17%
==========================================
Files 689 689
Lines 122048 122074 +26
Branches 17030 17036 +6
==========================================
+ Hits 95446 95685 +239
+ Misses 25698 25480 -218
- Partials 904 909 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Seems like Should be fixable by just adding aws-lc/tests/ci/integration/run_postgres_integration.sh Lines 50 to 51 in c15e28d |
| // we represent X509 chains as a CRYPTO_BUFFER stack. Therefore, we create a | ||
| // an internal copy and leave the |chain| parameter untouched. This means, |
There was a problem hiding this comment.
NP: "... We create a an internal copy ..."
| if (!ssl->config) { | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
NP: should we set an error here?
OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
| if (cert_pkey->chain) { | ||
| cert_pkey->chain.reset(); | ||
| } | ||
| cert_pkey->chain = std::move(certs); | ||
| cert->cert_private_key_idx = slot_idx; |
There was a problem hiding this comment.
NP: Maybe for a future PR -- since cert_pkey->chain is being replaced here, shouldn't the cache be invalidated? Otherwise a caller that previously triggered the cache population would see stale data after this call.
if (cert_pkey->chain) {
cert_pkey->chain.reset();
}
cert_pkey->chain = std::move(certs);
// Invalidate the parsed X509 chain cache for this slot since the backing
// CRYPTO_BUFFER chain was just replaced.
sk_X509_pop_free(cert_pkey->x509_chain, X509_free);
cert_pkey->x509_chain = nullptr;
cert->cert_private_key_idx = slot_idx;
Issues:
Addresses P400736589
Description of changes:
Describe AWS-LC’s current behavior and how your code changes that behavior. If there are no issues this pr is resolving, explain why this change is necessary.
Postgres recently started calling SSL_use_cert_and_key (the per-SSL
variant) which AWS-LC did not implement. This broke the postgres
integration test on both x86_64 and aarch64 with an undefined reference
linker error.
Extract the body of SSL_CTX_use_cert_and_key into a static helper
cert_use_cert_and_key(CERT *) and add SSL_use_cert_and_key as a thin
wrapper, following the established pattern used by SSL_use_PrivateKey,
ssl_set_cert, and cert_set_chain_and_key.
Testing:
How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?
CI
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.