Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Enable SSL Certificate authentication for etcd endpoint #677

Merged
merged 1 commit into from
Jul 27, 2014

Conversation

oalbiez
Copy link

@oalbiez oalbiez commented Jul 17, 2014

This pull request allows to connect etcd with certificate authentication.
Change are made for fleetctl and fleet

Some code could be factored between etcd and fleet... but I need this functionality now.
Could you merge before refactoring?

@tclavier tclavier mentioned this pull request Jul 18, 2014
@oalbiez
Copy link
Author

oalbiez commented Jul 21, 2014

In our cluster, we need certificate authentication. Can you review this pull request ? Thanks.

@@ -11,6 +11,9 @@ import (
type Config struct {
EtcdServers []string
EtcdKeyPrefix string
KeyFile string
Copy link
Contributor

Choose a reason for hiding this comment

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

Please prefix these new flags with "etcd", just like "etcd_servers" and "etcd_key_prefix"

@bcwaldon
Copy link
Contributor

@@ -356,3 +359,50 @@ func (ar *actionResolver) one(req *http.Request, cancel <-chan bool) (resp *http
log.V(1).Infof("etcd: recv response from %s %s: %s", req.Method, req.URL, resp.Status)
return
}

func GetTlsClientConfig(cafile string, keyfile string, certfile string) (*tls.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

"Get" is unnecessary, just call this TLSClientConfig

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some unit tests of this new function.

@oalbiez
Copy link
Author

oalbiez commented Jul 21, 2014

Thanks for your review. I made the corrections.

@@ -356,3 +359,50 @@ func (ar *actionResolver) one(req *http.Request, cancel <-chan bool) (resp *http
log.V(1).Infof("etcd: recv response from %s %s: %s", req.Method, req.URL, resp.Status)
return
}

func GetTLSClientConfig(cafile string, keyfile string, certfile string) (*tls.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you missed my comments on this function. I'll reiterate:

  1. Drop the Get from the function name
  2. Add some unittests of this function

@oalbiez
Copy link
Author

oalbiez commented Jul 22, 2014

Sorry, you are right I had missed your comment.
About unittests, as I am not familiar with golang, how do you prefer I test with key files? generating files? adding some demo key files to the repo?

@@ -356,3 +359,50 @@ func (ar *actionResolver) one(req *http.Request, cancel <-chan bool) (resp *http
log.V(1).Infof("etcd: recv response from %s %s: %s", req.Method, req.URL, resp.Status)
return
}

func TLSClientConfig(cafile string, keyfile string, certfile string) (*tls.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would help testability if you were passing in io.Readers rather than filenames. At that point, you can just generate objects on the fly and assert the proper *tls.Config is generated.

@oalbiez
Copy link
Author

oalbiez commented Jul 23, 2014

Thanks. I have added 3 unit tests.

@@ -8,6 +8,11 @@
# by the underlying go-etcd library.
# etcd_servers=["http://127.0.0.1:4001"]

# Provide TLS configuration when SSL certificate authentication is enabled in etcd endpoints
# etcd_cafile=path/to/CAfile
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you prepend / to "path/to/CAfile" and "path/to/keyfile"?

@bcwaldon
Copy link
Contributor

Just about there, thanks @oalbiez

@oalbiez
Copy link
Author

oalbiez commented Jul 24, 2014

@bcwaldon, do you agree on the generating files in unit tests ?

@bcwaldon
Copy link
Contributor

Sure, that'll work. Squash all of your commits down and we'll merge.

@oalbiez
Copy link
Author

oalbiez commented Jul 25, 2014

Commits squashed. Ready to be merged :)

@bcwaldon
Copy link
Contributor

@oalbiez One last thing. Please format your commit message per https://github.com/coreos/fleet/blob/master/CONTRIBUTING.md#format-of-the-commit-message

Provide TLS configuration when SSL certificate authentication is enabled in etcd endpoints.
Add configuration option for keyfile, certfile and cafile on both fleet and fleetctl.
@oalbiez
Copy link
Author

oalbiez commented Jul 25, 2014

Commit message updated.

@bcwaldon
Copy link
Contributor

@oalbiez thanks, looks much better. I'm going to functionally test this over the weekend and get it in to the v0.6.0 release on Monday.

@bcwaldon bcwaldon added this to the v0.6.0 milestone Jul 26, 2014
bcwaldon added a commit that referenced this pull request Jul 27, 2014
Enable SSL Certificate authentication for etcd endpoint
@bcwaldon bcwaldon merged commit c6f371e into coreos:master Jul 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants