-
Notifications
You must be signed in to change notification settings - Fork 537
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
Add regression testing for https_port certificate loading #154
base: master
Are you sure you want to change the base?
Conversation
@chtsanti , in PRF#144 michaeladm mentioned the certtool created certificates did not work for bumping. You might want to test the bumping process with the certs created by the script here |
I am not sure it is important that the test certificates work outside of their test cases, but requiring certtool availability for running these tests is one concern that did not make it into my review (IIRC). How about generating certificates during bootstrapping, so that Squid tarball users can run full tests without relying on any particular certificate manipulation program being installed? |
I'm being a bit paranoid here with the timing and cert creation. Having them only be built when actually needed avoids any issues that might crop up with our tarballs containing crypto keys (might confuse some people or tools that check for such things). |
9b8f58a
to
e869df3
Compare
90c47d8
to
2b56873
Compare
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.
Great progress, thank you. I left a few questions and a couple of should-be-easy-to-address suggestions.
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.
Most of these change requests require changes in more places than just code they are attached to, going beyond that code-specific suggestions. Please interpret them accordingly.
P.S. I am ignoring CI test failures in this review iteration.
prompt= no | ||
x509_extensions= root_ca_extensions | ||
[ root_ca_distinguished_name ] | ||
organizationName= Example.Org |
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.
Feels wrong to use a domain that can be reached on the internet and has a "real" trusted certificate. This code is not "documentation" that example.org
is meant for. Can we use a .test
TLD instead? I think such usage would follow RFC 2606 recommendations and be compatible with RFC 6761 requirements on other agents.
With the transition to .test
TLD, we can make this name more specific to this certificate meaning. For example:
organizationName= Example.Org | |
organizationName = Root.Test |
Similar changes would need to be done elsewhere, of course. They would make associated names easier to grok in triage (than, for example, trying to remember the role difference between example.org
and example.net
and example.com
!).
commonName= Test CA. Do not Trust | ||
[ root_ca_extensions ] | ||
basicConstraints = CA:true | ||
" > example.org-ca |
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.
Please use a more telling/specific name for this and similar files. Do not force us to remember the difference between "example.org", "example.com", and "example.net" when looking through artifacts or triage logs! And please use a filename extension to hint an how this configuration file is used. For example:
" > example.org-ca | |
" > root-ca.conf |
or
" > example.org-ca | |
" > ca-root.conf |
Other names would need to be adjusted accordingly, of course.
preserve= no | ||
[ req ] | ||
distinguished_name= root_ca_distinguished_name | ||
prompt= no |
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.
For readability and consistency sake, please use the same assignment style throughout configuration files, with spaces around =
. The change below is just an illustration -- more lines will need to be adjusted:
prompt= no | |
prompt = no |
cat leaf-rsa.crt ca-root-rsa.crt > leaf-chain-nokey-rsa.pem | ||
|
||
else | ||
echo "WARNING: cannot find a tool to generate certificates" |
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 is a (fatal) error for this script, not just a warning:
echo "WARNING: cannot find a tool to generate certificates" | |
echo "ERROR: Cannot find a tool to generate certificates" |
cat leaf-rsa.pkey leaf-rsa.crt > leaf-key-rsa.pem | ||
cat leaf-rsa.crt ca-root-rsa.crt > leaf-chain-nokey-rsa.pem |
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.
The other files are following a reasonable naming scheme, but the last two use a different scheme that names the same kind of file differently and starts using a vague word "chain". Let's apply the earlier naming scheme/pattern to the last two entries as well:
cat leaf-rsa.pkey leaf-rsa.crt > leaf-key-rsa.pem | |
cat leaf-rsa.crt ca-root-rsa.crt > leaf-chain-nokey-rsa.pem | |
cat leaf-rsa.pkey leaf-rsa.crt > leaf-rsa.pem | |
cat leaf-rsa.crt ca-root-rsa.crt > leaf-root-nokey-rsa.pem |
# 1) leaf only tls-cert=./leaf-rsa.* | ||
# 2) full chain tls-cert=./leaf-root-rsa.* | ||
# 3) root CA tls-cert=./ca-root-rsa.* | ||
# 4) incomplete chain tls-cert=./ca-mid-rsa.* |
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.
There are other incomplete chains here IMO. And this one does not really chain anything. Let's be specific and more consistent:
# 4) incomplete chain tls-cert=./ca-mid-rsa.* | |
# 4) intermediate CA only tls-cert=./ca-mid-rsa.* |
# 2) on tls-generate-host-certificates=on | ||
# 3) off tls-generate-host-certificates=off | ||
# 4) auto tls-generate-host-certificates | ||
# 5) FILE tls-generate-host-certificates=./ca-mid-root-rsa.pem |
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.
Please drop this invalid setting/variation (C5): This PR focuses on testing "certificate loading". The corresponding tests are not about testing our ability to parse boolean options like tls-generate-host-certificates. This PR does not even focus on parsing options that do specify certificate filenames.
# 5) FILE tls-generate-host-certificates=./ca-mid-root-rsa.pem |
If there is enough value in testing tls-generate-host-certificates=garbage
, a different PR should add a different test. This "certificate loading" PR is best without such testing.
# A) certificate(s): | ||
# 1) leaf only tls-cert=./leaf-rsa.* | ||
# 2) full chain tls-cert=./leaf-root-rsa.* | ||
# 3) root CA tls-cert=./ca-root-rsa.* |
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.
For consistency with "leaf only" in item 1.
# 3) root CA tls-cert=./ca-root-rsa.* | |
# 3) root CA only tls-cert=./ca-root-rsa.* |
Alternatively, we can drop "only" from all entries.
AM_CONDITIONAL(ENABLE_CERT_TESTS,[ test "x$with_openssl" = "xyes" -o "x$with_gnutls" != "xno"]) | ||
AC_SUBST(SSLLIB) |
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.
Please move this line down and visually separate it from OpenSSL-specific code. It is not specific to OpenSSL. It covers both GnuTLS and OpenSSL cases (handled above).
AM_CONDITIONAL(ENABLE_CERT_TESTS,[ test "x$with_openssl" = "xyes" -o "x$with_gnutls" != "xno"]) | |
AC_SUBST(SSLLIB) | |
AC_SUBST(SSLLIB) | |
AM_CONDITIONAL(ENABLE_CERT_TESTS,[ test "x$with_openssl" = "xyes" -o "x$with_gnutls" != "xno"]) |
@@ -1135,11 +1136,13 @@ AS_IF([test "x$with_openssl" = "xyes"],[ | |||
SQUID_CHECK_OPENSSL_CONST_SSL_SESSION_CB_ARG | |||
SQUID_CHECK_OPENSSL_CONST_X509_GET0_SIGNATURE_ARGS | |||
SQUID_CHECK_OPENSSL_TXTDB | |||
AC_PATH_PROG(OPENSSL_BIN, openssl) |
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.
Do we really want to ENABLE_CERT_TESTS (below) when neither openssl nor certool binaries are not found (i.e., neither OPENSSL_BIN nor CERTTOOL_BIN variables are defined)?
Should not we ENABLE_CERT_TESTS (below) when Squid is built with GnuTLS but only openssl binary is found (i.e., OPENSSL_BIN is defined but CERTTOOL_BIN is not)? It is currently not enabled in that case AFAICT. Same for OpenSSL+certool combination.
It feels like AC_PATH_PROG() tests for OPENSSL_BIN and CERTTOOL_BIN should be made independent from the corresponding libraries and ENABLE_CERT_TESTS preconditions adjusted to enable testing in more environments where such testing should work.
mk-tls-test-certs.sh depends on receiving empty string instead of /bin/false when tools are unavailable
Since our unit testing cannot yet handle FATAL exits of Squid as a
successful test result, some https_port settings are commented out for
now. They should be checked manually if altering the relevant code.
Likewise, ssl-bump testing cannot be done yet because the OpenSSL
specific code is not always built (minimal build test layer).
This test creates some temporary CA certificates and keys as-needed. The
script checks for certtool or openssl CLI existence.