Skip to content

transport: add possibility to use TLS secured transport layer#236

Merged
tonistiigi merged 3 commits into
moby:masterfrom
trusch:feature/tls-transport
Dec 21, 2017
Merged

transport: add possibility to use TLS secured transport layer#236
tonistiigi merged 3 commits into
moby:masterfrom
trusch:feature/tls-transport

Conversation

@trusch
Copy link
Copy Markdown
Contributor

@trusch trusch commented Dec 20, 2017

What

This PR adds logic and commandline flags for buildkitd and buildctl to configure TLS certificates, keys and CA certificates.

There are now the following three options:

  • Use no TLS, the whole thing is opt-in and completely backward compatible
  • Use a certificate and key on the server and a ca-certificate at the client
    • an ephemeral key exchange is performed
    • the client verifies the server certificate
  • Use cert, key and ca-cert on server and client
    • the connection is verified by both ends

From the API perspective this is implemented as the ClientOption WithCredentials() which takes pathes to the requested files as arguments.

Why

To be able to effectively prevent man in the middle attacks or unauthorized access in unsecure networks, using TLS is the way to go in the current gRPC setup.

Comment thread cmd/buildkitd/main.go Outdated
certPool := x509.NewCertPool()
ca, err := ioutil.ReadFile(caFile)
if err != nil {
return nil, fmt.Errorf("could not read ca certificate: %s", err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: errors.Wrap

@trusch
Copy link
Copy Markdown
Contributor Author

trusch commented Dec 20, 2017

Sorry for the test failures, I did simply forgot to run them locally. Will do many manual testing + do the simple make test before next push ;)

@trusch trusch force-pushed the feature/tls-transport branch from 316c849 to 03f717b Compare December 20, 2017 12:31
@trusch
Copy link
Copy Markdown
Contributor Author

trusch commented Dec 20, 2017

@AkihiroSuda all checks passed, and I rebased to master for cleaner history. Hope to get this merged soon, especially because client auth is very urgent for my usecase ;)

Copy link
Copy Markdown
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

I wonder if these options should be defined per listener instead of per daemon. Is there ever a need to use this for unix sockets? It would be somewhat clearer to me if tls would be used if you specify tls:// on the client/server --addr flag and not if tcp or unix sockets are used there. And if you listen/dial on tls:// and don't provide these values it would error.

Even if you have a use case for tls on local connections I don't think we need --server-name on the client. It should be determined from the address and in case of local connection, it doesn't matter.

@vdemeester PTAL

Comment thread cmd/buildctl/main.go Outdated
Value: "",
},
cli.StringFlag{
Name: "ca-cert",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use the same flags as docker for consistency. tlscacert etc.

…sistency with docker + guess tls-server-name from target address in client if not specified explicitly;
@trusch
Copy link
Copy Markdown
Contributor Author

trusch commented Dec 21, 2017

I renamed the commandline flags to be consistent with the docker flags and I get the name of the server from the address of not specified explicit. That way the user must not supply it, but can do so.

TLS itself is agnostic about the used underlying transport, so I would say that a tls:// scheme wouln't be consistent with tcp:// and unix:// schemes because it means something different. @tonistiigi

Copy link
Copy Markdown
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Same as @trusch on tls://it feels weird. Other than that, looks good to me 😉

Comment thread cmd/buildctl/main.go
Usage: "buildkitd address",
Value: defaultAddress,
},
cli.StringFlag{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What would be the use case of this one ? a certificate issued for another address than the specified addr ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Imagine you have your certificates generated for a specific addressd and your buildserver is running, but you need to access it directly via IP because your DNS is broken or you have setup some port-forwarding to debug things in for example a k8s deployment.

Then it would be usefull to be able to tell the client which name it should expect in the servers certificate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok 😛 sounds fair 👼

Copy link
Copy Markdown
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

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.

4 participants