Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yadij
Copy link
Contributor

@yadij yadij commented Feb 20, 2018

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.

@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Feb 20, 2018
@yadij
Copy link
Contributor Author

yadij commented Feb 20, 2018

@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

@rousskov rousskov self-requested a review February 21, 2018 02:44
rousskov

This comment was marked as resolved.

@rousskov
Copy link
Contributor

In PR #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?

@yadij yadij changed the title Add regression testing for squid.conf https_port certificate loading WIP: Add regression testing for squid.conf https_port certificate loading Feb 25, 2018
@yadij
Copy link
Contributor Author

yadij commented Feb 26, 2018

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).

@yadij yadij force-pushed the tls-testing branch 2 times, most recently from 9b8f58a to e869df3 Compare April 14, 2018 11:16
@yadij yadij changed the title WIP: Add regression testing for squid.conf https_port certificate loading WIP: Add regression testing for https_port certificate loading May 6, 2018
@yadij yadij changed the title WIP: Add regression testing for https_port certificate loading Add regression testing for https_port certificate loading May 12, 2018
@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label May 12, 2018
@yadij yadij added the S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box label May 12, 2018
@yadij yadij force-pushed the tls-testing branch 2 times, most recently from 90c47d8 to 2b56873 Compare June 12, 2018 19:29
Copy link
Contributor

@rousskov rousskov left a 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.

test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/squidconf/tls-certs Outdated Show resolved Hide resolved
test-suite/mk-tls-test-certs.sh Outdated Show resolved Hide resolved
@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Jul 12, 2018
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jul 18, 2019
@yadij yadij added the backport-to-v5 maintainer has approved these changes for v5 backporting label Dec 23, 2019
@yadij yadij added the review-2 label Mar 20, 2020
@yadij yadij removed the S-waiting-for-author author action is expected (and usually required) label Mar 27, 2020
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Oct 15, 2021
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Mar 22, 2022
@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 8, 2022
@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Aug 23, 2022
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Mar 27, 2023
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Dec 12, 2023
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jan 9, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Jan 24, 2024
@kinkie kinkie added the M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels label Feb 3, 2024
@yadij yadij removed S-waiting-for-author author action is expected (and usually required) M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels labels May 9, 2024
@yadij yadij requested a review from rousskov May 9, 2024 04:51
@yadij yadij added the S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box label May 9, 2024
Copy link
Contributor

@rousskov rousskov left a 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
Copy link
Contributor

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:

Suggested change
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
Copy link
Contributor

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:

Suggested change
" > example.org-ca
" > root-ca.conf

or

Suggested change
" > 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
Copy link
Contributor

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:

Suggested change
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"
Copy link
Contributor

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:

Suggested change
echo "WARNING: cannot find a tool to generate certificates"
echo "ERROR: Cannot find a tool to generate certificates"

Comment on lines +124 to +125
cat leaf-rsa.pkey leaf-rsa.crt > leaf-key-rsa.pem
cat leaf-rsa.crt ca-root-rsa.crt > leaf-chain-nokey-rsa.pem
Copy link
Contributor

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:

Suggested change
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.*
Copy link
Contributor

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:

Suggested change
# 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
Copy link
Contributor

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.

Suggested change
# 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.*
Copy link
Contributor

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.

Suggested change
# 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.

Comment on lines +1145 to 1121
AM_CONDITIONAL(ENABLE_CERT_TESTS,[ test "x$with_openssl" = "xyes" -o "x$with_gnutls" != "xno"])
AC_SUBST(SSLLIB)
Copy link
Contributor

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).

Suggested change
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)
Copy link
Contributor

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.

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels May 16, 2024
@kinkie kinkie added the M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels label Nov 1, 2024
yadij added 2 commits January 18, 2025 20:41
mk-tls-test-certs.sh depends on receiving empty string
instead of /bin/false when tools are unavailable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels S-waiting-for-author author action is expected (and usually required)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants