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

Regenerate certificates to use SANs instead of Common Name #2461

Merged
merged 5 commits into from
Sep 12, 2020

Conversation

albertteoh
Copy link
Contributor

Signed-off-by: albertteoh albert.teoh@logz.io

Which problem is this PR solving?

Proposed fix to a failing test caused by Go 1.15 dropping support for Common Names.

Please let me know if there is a better way of generating certs using SANs or if any configurations appear spurious, as this is pretty new to me.

Closes #2435

Short description of the changes

@albertteoh albertteoh requested a review from a team as a code owner September 9, 2020 11:52
.travis.yml Outdated
@@ -7,6 +7,44 @@ dist: bionic

matrix:
include:
# Go 1.15
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to get matrix expansion working here, but figured it's pretty important to avoid silent regressions on Go 1.15 builds.

Was hoping we could simply add:

go:
- 1.14.x
- 1.15.x

and remove the references to 1.14.x in the matrix.include list, but it seems go can't be expanded into the matrix.

Suggestions welcome!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the build now passes for 1.15, I suggest we just update 1.14 -> 1.15, instead of duplicating (the CI already runs for too long, we don't have capacity to double the number of steps).

We may want to add one extra step to run unit tests & lint with go tip (but I would do it in a separate PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, updated to 1.15.
Where can I learn more about "go tip"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would an additional "tip" build version result in doubling the number of steps (1.15 + tip)?

@codecov
Copy link

codecov bot commented Sep 9, 2020

Codecov Report

Merging #2461 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2461      +/-   ##
==========================================
+ Coverage   95.57%   95.59%   +0.01%     
==========================================
  Files         208      208              
  Lines       10690    10690              
==========================================
+ Hits        10217    10219       +2     
+ Misses        401      399       -2     
  Partials       72       72              
Impacted Files Coverage Δ
...lugin/sampling/strategystore/adaptive/processor.go 100.00% <0.00%> (+0.79%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5508165...f361cda. Read the comment docs.

@@ -1,35 +1,60 @@
# Example Certificate Authority and Certificate creation for testing

The following commands were used to create the CA, server and client's certificates and keys
The following commands were used to create the CA, server and client's certificates and keys. These certificates use the Subject Alternative Name extension rather than the Common Name, which will be unsupported in Go 1.15.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious:

  • couldn't we just move all of this into a script, instead of a run book?
  • is there a flag to for "accept defaults" to make the script even less interactive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, and yes, there's a way to accept defaults. I've modified this README file into a bash script.

.travis.yml Outdated
@@ -7,6 +7,44 @@ dist: bionic

matrix:
include:
# Go 1.15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the build now passes for 1.15, I suggest we just update 1.14 -> 1.15, instead of duplicating (the CI already runs for too long, we don't have capacity to double the number of steps).

We may want to add one extra step to run unit tests & lint with go tip (but I would do it in a separate PR).

albertteoh added 3 commits September 10, 2020 09:50
Signed-off-by: albertteoh <albert.teoh@logz.io>
Signed-off-by: albertteoh <albert.teoh@logz.io>
Signed-off-by: albertteoh <albert.teoh@logz.io>
pkg/config/tlscfg/testdata/gen-certs.sh Show resolved Hide resolved
# Generate config files.
# The server name (under alt_names in the ssl.conf) is `example.com`. (in accordance to [RFC 2006](https://tools.ietf.org/html/rfc2606))
source gen-ssl-conf.sh example.com ssl.conf
source gen-ssl-conf.sh wrong.com wrong-ssl.conf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps instead of writing to the current dir (and accidentally checking in), we could use temp dir

tmp_dir=$(mktemp -d -t certificates)
clean_up () {
    ARG=$?
    rm -rf $tmp_dir
    exit $ARG
} 
trap clean_up EXIT

-CA example-CA-cert.pem \
-CAkey example-CA-key.pem \
-CAcreateserial \
-extfile ssl.conf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about writing PEM files into $tmp_dir and then copying into the right place in the source tree?

printf "A script to generate SSL configuration files for testing purposes.\n\n"
printf "Usage: ssl-conf-gen.sh DOMAIN_NAME OUTPUT_FILE\n\n"
printf "Example: ssl-conf-gen.sh example.com ssl.conf\n"
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be exit -1 instead?

Copy link
Contributor Author

@albertteoh albertteoh Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe negative numbers are not supported as return codes in bash. But good catch that it should return a non-0 return code.

return was intentional because this script is sourced, which means it runs within the parent shell.

The added benefit of source-ing is that the set -ex that you suggested above will also apply in this script so commands in this script are printed to STDOUT and will also trigger an early exit if something fails.

If developers want to call this script separately, it can be run with source gen-ssl-conf.sh <args...>.

@@ -1,35 +0,0 @@
# Example Certificate Authority and Certificate creation for testing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the README with some basic instruction how to regenerate certificates, preferably via a make command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md and Makefile added.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually referring to the main Makefile. If it's just in this dir then I would simply provide instructions for running the script directly.

pkg/config/tlscfg/testdata/README.md Outdated Show resolved Hide resolved
pkg/config/tlscfg/testdata/gen-certs.sh Outdated Show resolved Hide resolved
@@ -1,35 +0,0 @@
# Example Certificate Authority and Certificate creation for testing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually referring to the main Makefile. If it's just in this dir then I would simply provide instructions for running the script directly.

Signed-off-by: albertteoh <albert.teoh@logz.io>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉 🎉

@yurishkuro
Copy link
Member

one of the commits is not signed (probably the merge). You may want to squash into one:

https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md#missing-sign-offs

Signed-off-by: albertteoh <albert.teoh@logz.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Go 1.15 compatiblity
2 participants