-
Notifications
You must be signed in to change notification settings - Fork 3.9k
go/proxyd: Add support for additional SSL certs #1818
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
Merged
mslipper
merged 1 commit into
ethereum-optimism:develop
from
mslipper:feat/additional-certs
Nov 29, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@eth-optimism/proxyd': patch | ||
| --- | ||
|
|
||
| Add support for additional SSL certificates in Docker container |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/sh | ||
|
|
||
| echo "Updating CA certificates." | ||
| update-ca-certificates | ||
| echo "Running CMD." | ||
| exec "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package proxyd | ||
|
|
||
| import ( | ||
| "crypto/tls" | ||
| "crypto/x509" | ||
| "errors" | ||
| "io/ioutil" | ||
| ) | ||
|
|
||
| func CreateTLSClient(ca string) (*tls.Config, error) { | ||
| pem, err := ioutil.ReadFile(ca) | ||
| if err != nil { | ||
| return nil, wrapErr(err, "error reading CA") | ||
| } | ||
|
|
||
| roots := x509.NewCertPool() | ||
| ok := roots.AppendCertsFromPEM(pem) | ||
| if !ok { | ||
| return nil, errors.New("error parsing TLS client cert") | ||
| } | ||
|
|
||
| return &tls.Config{ | ||
| RootCAs: roots, | ||
| }, nil | ||
| } | ||
|
|
||
| func ParseKeyPair(crt, key string) (tls.Certificate, error) { | ||
| cert, err := tls.LoadX509KeyPair(crt, key) | ||
| if err != nil { | ||
| return tls.Certificate{}, wrapErr(err, "error loading x509 key pair") | ||
| } | ||
| return cert, nil | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't this step happen at build time to make it reproducible?
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.
update-ca-certificatesneeds to be run whenever the supplied certificates change. Since we support bind-mounting the certificates at runtime, this needs to happen before executing the proxyd binary.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.
Updating certs from the internet at runtime is asking for trouble.
Can we default to the container CA certs, but allow specifying a CA file at runtime (end drop the entrypoint script)?
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.
update-ca-certificatesdoesn't update certs from the internet, it just appends all certs in theca-certificatesdirectory into one big file in/etc/ssl: https://gitlab-test.alpinelinux.org/alpine/ca-certificates/-/blob/master/update-ca.c.That said, I think it's also useful to specify a CA file at runtime for things like client certificates, so I've added that functionality.
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.
Got it, I thought that
update-ca-certificatescalled out to the network and downloaded the latest certs from the alpine registry