Skip to content

Commit

Permalink
Add the CA bundle auto fallback for FROM scratch docker from fortio/m…
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Jun 23, 2024
1 parent 1396d96 commit 791dfb6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,13 @@ Short 'numeric' version (v skipped, useful for docker image tags etc)
% multicurl version
1.10.1
```
### https/tls in FROM scratch docker images
You should always try to use `FROM scratch` Docker images when possible,
it's one of the strength of go.
Using this `fortio.org/cli` as a base makes it work
for TLS by defaulting to the bundle provided by `golang.org/x/crypto/x509roots/fallback` automatically.
See https://github.com/fortio/multicurl for a good example.
5 changes: 5 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ import (

"fortio.org/log"
"fortio.org/version"
_ "golang.org/x/crypto/x509roots/fallback" // This is a base for main, see extended comment below.
)

// golang.org/x/crypto/x509roots/fallback blank import above is because this is a base for all our main package,
// the CA bundle is needed for FROM scratch images to work with outcalls to internet valid TLS certs (https).
// See https://github.com/fortio/multicurl/pull/146 for instance.

// Configuration for your Main() or ServerMain() function.
// These variables is how to setup the arguments, flags and usage parsing for [Main] and [ServerMain].
// At minium set the MinArgs should be set.
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.18
require (
fortio.org/log v1.12.2
fortio.org/version v1.0.4
golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8
)

require fortio.org/struct2env v0.4.0 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ fortio.org/struct2env v0.4.0 h1:k5alSOTf3YHiB3MuacjDHQ3YhVWvNZ95ZP/a6MqvyLo=
fortio.org/struct2env v0.4.0/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410=
fortio.org/version v1.0.4 h1:FWUMpJ+hVTNc4RhvvOJzb0xesrlRmG/a+D6bjbQ4+5U=
fortio.org/version v1.0.4/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8 h1:+kWDWI3Eb5cPIOr4cP+R2RLDwK3/dXppL+7XmSOh2LA=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=

0 comments on commit 791dfb6

Please sign in to comment.