Skip to content
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

*: support ssl/tls #868

Merged
merged 17 commits into from
Dec 1, 2017
Merged

*: support ssl/tls #868

merged 17 commits into from
Dec 1, 2017

Conversation

Connor1996
Copy link
Member

@Connor1996 Connor1996 commented Nov 26, 2017

As mentioned in #865
pd-ctl and pd-client can connect with pd in ssl/tls connection, and etcd-client with etcd-server too.
when tls-ca-path in config.toml is set, the connection among etcd peers will also use ssl/tls with auto generated cert and key file.

note: relative urls should use https schema, or it will still not use ssl/tls

when using ssl/tls, there is a bug of embed etcd that will cause panic when stopping pd process.
etcd-io/etcd#8916

}

// NewClient creates a PD client.
func NewClient(pdAddrs []string) (Client, error) {
func NewClient(pdAddrs []string, tlsCAPath, tlsCertPath, tlsKeyPath string) (Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

move these to a SecurityOption struct.

@siddontang
Copy link
Contributor

I prefer to follow https://coreos.com/etcd/docs/latest/op-guide/security.html and use the same name flag.

Btw, I don't think we need to support auto TLS now.

/cc @disksing

conf/config.toml Outdated
# Path of file that contains X509 key in PEM format.
tls-key-path = ""
# enable client certificate auth, if true following two settings shouldn't be empty
client-cert-auth = false
Copy link
Contributor

Choose a reason for hiding this comment

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

As follower pd-servers redirect all requests to leader, so typically if if TLS is enabled on server side, client side must enable it too. Therefore I think this flag looks redundant to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

@disksing @huachaohuang

Maybe we should let the client redirect to the new leader to reduce the latency.

}

// Append the certificates from the CA
if ok := certPool.AppendCertsFromPEM(ca); !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

if !certPool.AppendCertsFromPEM(ca) {

}

// Append the certificates from the CA
if ok := certPool.AppendCertsFromPEM(ca); !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

if !certPool.AppendCertsFromPEM(ca) {

@disksing
Copy link
Contributor

LGTM. Have you tested it with tikv-server?

@Connor1996
Copy link
Member Author

@disksing Yes

@siddontang
Copy link
Contributor

siddontang commented Nov 30, 2017

Rest LGTM

server/config.go Outdated
@@ -85,6 +85,10 @@ type Config struct {
// ElectionInterval is the interval for etcd Raft election.
ElectionInterval typeutil.Duration `toml:"election-interval"`

TLSCAPath string `toml:"tls-cacert-path" json:"tls-cacert-path"`
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 we can remove tls and use a security section like TiKV does

Copy link
Contributor

Choose a reason for hiding this comment

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

url string
detach bool
version bool
CAPath string
Copy link
Contributor

Choose a reason for hiding this comment

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

why public?

@Connor1996
Copy link
Member Author

PTAL @siddontang @disksing

Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

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

LGTM

@disksing disksing merged commit 21d09c1 into tikv:master Dec 1, 2017
@Connor1996 Connor1996 deleted the support-ssl/tls branch December 1, 2017 08:43
@Connor1996
Copy link
Member Author

Fix #865

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.

3 participants