Skip to content

Refactor TLS code with a new tlsconfig package#13636

Merged
icecrime merged 1 commit intomoby:masterfrom
tiborvass:refactor-tls
Jun 5, 2015
Merged

Refactor TLS code with a new tlsconfig package#13636
icecrime merged 1 commit intomoby:masterfrom
tiborvass:refactor-tls

Conversation

@tiborvass
Copy link
Copy Markdown
Contributor

This patch creates a new tlsconfig package to handle creation of
secure-enough TLS configurations for clients and servers.

The package was created by refactoring TLS code in the client and the
daemon. After this patch, it is expected that all code creating TLS
configurations use this tlsconfig package for greater security,
consistency and readability.

On the server side, this fixes a bug where --tlsverify was not taken
into account. Now, if specified, it will require the client to
authenticate.

Signed-off-by: Tibor Vass tibor@docker.com

Note: this patch does not modify code under registry/ although it is expected for other patches touching code that creates TLS configurations (including registry/), to reuse this tlsconfig package.

Ping @diogomonica @NathanMcCauley @dmcgowan @docker/core-maintainers

@calavera
Copy link
Copy Markdown
Contributor

calavera commented Jun 1, 2015

do we really need a new package just for this configuration? maybe it should live within the sockets package. We could also rename that package to something else if it's not descriptive enough.

@tiborvass
Copy link
Copy Markdown
Contributor Author

@calavera in my opinion, yes.

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.

I find this weird but it was like that: https://github.com/docker/docker/pull/13636/files#diff-d6f439c36bc4930ab43c13d5ad3868d2L58

I wonder if this shouldn't be if ca != "" && verify {, on the other hand, why would you provide a CA if you don't want to verify the 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.

The verify flag has no meaning in this context, if the CA is provided the client should always be verified against it. Using require any client certificate has no value unless you plan on using the certificate for something else after after the handshake.

@diogomonica
Copy link
Copy Markdown
Contributor

I don't see any issues with this. LGTM

@aluzzardi
Copy link
Copy Markdown
Member

/cc @ehazlett @nathanleclaire for machine

@ehazlett
Copy link
Copy Markdown
Contributor

ehazlett commented Jun 1, 2015

Yes!! Thanks!

On Monday, June 1, 2015, Andrea Luzzardi notifications@github.com wrote:

/cc @ehazlett https://github.com/ehazlett @nathanleclaire
https://github.com/nathanleclaire for machine


Reply to this email directly or view it on GitHub
#13636 (comment).

docker/docker.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is why you have a broken CI test on janky.. currently TestRunTLSverify assumes that specifying --tls-verify without enabling tls will cause a docker run failure, but it isn't anymore.

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.

yes fixing now :) Thanks!

@nathanleclaire
Copy link
Copy Markdown
Contributor

Nice.

@tiborvass tiborvass force-pushed the refactor-tls branch 2 times, most recently from 5ddf913 to 5a9f05e Compare June 1, 2015 19:53
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.

@dmcgowan verify is never used here, should we remove it?

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.

I vote remove it, it is unused and without meaning

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TLSConfig

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.

Will fix

@stevvooe
Copy link
Copy Markdown
Contributor

stevvooe commented Jun 1, 2015

@tiborvass This looks like a good change. I would prefer to call it tlcconf or something like that, rather than overload the "util" terminology.

@aluzzardi
Copy link
Copy Markdown
Member

ping @vieux @abronan

This is awesome - we have exactly that same code in Swarm. We could replace it with this pkg.

I agree with @stevvooe - tlsconfig or something less generic.

@tiborvass
Copy link
Copy Markdown
Contributor Author

@aluzzardi @stevvooe I can rename it to tlsconfig and have the functions be New(), Client() and Server()

@tiborvass tiborvass changed the title Refactor TLS code with a new tlsutil package Refactor TLS code with a new tlsconfig package Jun 1, 2015
@tiborvass
Copy link
Copy Markdown
Contributor Author

Renamed the package from tlsutil to tlsconfig, and changed the name of the functions as well to make them shorter.

@stevvooe
Copy link
Copy Markdown
Contributor

stevvooe commented Jun 1, 2015

There are still a few docs and naming issues but they don't matter.

LGTM!

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.

(OCD warning ;-)) change to "Could not load ...", to be consistent with the other errors? (Don't forget the related test)

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.

fixing

@tiborvass tiborvass force-pushed the refactor-tls branch 2 times, most recently from 82b06b8 to 855db5a Compare June 5, 2015 02:25
@NathanMcCauley
Copy link
Copy Markdown
Contributor

LGTM

@tiborvass tiborvass force-pushed the refactor-tls branch 2 times, most recently from ccb860f to 6460f90 Compare June 5, 2015 12:37
docker/docker.go Outdated
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.

This logic is backwards, it should only check this if the flag is NOT set. When the flag is set, then not exists should cause an error later on. This should only check if the default file exists if the flag is not set.

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.

nice catch... fixing

@icecrime
Copy link
Copy Markdown
Contributor

icecrime commented Jun 5, 2015

@jfrazelle Still LGTM for you?

@jessfraz
Copy link
Copy Markdown
Contributor

jessfraz commented Jun 5, 2015

re LGTM

@icecrime
Copy link
Copy Markdown
Contributor

icecrime commented Jun 5, 2015

Waiting on CI.

@estesp
Copy link
Copy Markdown
Contributor

estesp commented Jun 5, 2015

I'm testing the actual options based on the docs list of supported settings. But if someone else has already finished that then I'm fine with the existing LGTMs

Sent from my iPhone

On Jun 5, 2015, at 12:06 PM, Arnaud Porterie notifications@github.com wrote:

Waiting on CI.


Reply to this email directly or view it on GitHub.

@icecrime
Copy link
Copy Markdown
Contributor

icecrime commented Jun 5, 2015

Well, tests fail: back to 2-needs-code-review, ping @tiborvass.

This patch creates a new `tlsconfig` package to handle creation of
secure-enough TLS configurations for clients and servers.

The package was created by refactoring TLS code in the client and the
daemon. After this patch, it is expected that all code creating TLS
configurations use this `tlsconfig` package for greater security,
consistency and readability.

On the server side, this fixes a bug where --tlsverify was not taken
into account. Now, if specified, it will require the client to
authenticate.

Signed-off-by: Tibor Vass <tibor@docker.com>
@tiborvass
Copy link
Copy Markdown
Contributor Author

Fixed the failing test.

@dmcgowan
Copy link
Copy Markdown
Member

dmcgowan commented Jun 5, 2015

LGTM

icecrime pushed a commit that referenced this pull request Jun 5, 2015
Refactor TLS code with a new `tlsconfig` package
@icecrime icecrime merged commit efe5c64 into moby:master Jun 5, 2015
@ewindisch
Copy link
Copy Markdown
Contributor

Great. LGTM, although I'd love to see the server and client have separate defaults. That could easily come in a follow-up patch.

@tiborvass tiborvass deleted the refactor-tls branch July 17, 2019 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.