-
Notifications
You must be signed in to change notification settings - Fork 648
GnuTLS: load and send X.509 certificate chains #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,7 +239,7 @@ Security::ServerOptions::createStaticServerContext(AnyP::PortCfg &) | |
| return false; | ||
| } | ||
|
|
||
| for (auto cert : keys.chain) { | ||
| for (const auto &cert : keys.chain) { | ||
| if (SSL_CTX_add_extra_chain_cert(t.get(), cert.get())) { | ||
| // increase the certificate lock | ||
| X509_up_ref(cert.get()); | ||
|
|
@@ -251,9 +251,20 @@ Security::ServerOptions::createStaticServerContext(AnyP::PortCfg &) | |
|
|
||
| #elif HAVE_LIBGNUTLS | ||
| for (auto &keys : certs) { | ||
| gnutls_x509_crt_t crt = keys.cert.get(); | ||
| gnutls_x509_privkey_t xkey = keys.pkey.get(); | ||
| const auto x = gnutls_certificate_set_x509_key(t.get(), &crt, 1, xkey); | ||
|
|
||
| const auto certCount = 1 + keys.chain.size(); | ||
| auto crt = new gnutls_x509_crt_t[certCount]; | ||
| crt[0] = keys.cert.get(); | ||
| if (certCount > 1) { | ||
| int i = 1; | ||
| for (const auto &cert : keys.chain) { | ||
| crt[i++] = cert.get(); // gnutls_x509_crt_t is a raw-pointer | ||
| } | ||
| } | ||
|
|
||
| const auto x = gnutls_certificate_set_x509_key(t.get(), crt, certCount, xkey); | ||
| delete[] crt; | ||
|
Comment on lines
+256
to
+267
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please refactor to use std::vector instead of raw new/delete. Use std::vector::data() to pass the raw array to gnutls_certificate_set_x509_key(). I expect
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem right to me. It assumes that
|
||
| if (x != GNUTLS_E_SUCCESS) { | ||
| SBuf whichFile = keys.certFile; | ||
| if (keys.certFile != keys.privateKeyFile) { | ||
|
|
@@ -263,7 +274,6 @@ Security::ServerOptions::createStaticServerContext(AnyP::PortCfg &) | |
| debugs(83, DBG_CRITICAL, "ERROR: Failed to initialize server context with keys from " << whichFile << ": " << Security::ErrorString(x)); | ||
| return false; | ||
| } | ||
| // XXX: add cert chain to the context | ||
| } | ||
| #endif | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file changes result from incremental review polishing. The original change around these was split off into an already merged PR without this pointer-safety action.
TODO: split this off also.