@@ -18,6 +18,7 @@ import (
18
18
"crypto/tls"
19
19
"crypto/x509"
20
20
"fmt"
21
+ "github.com/coreos/etcd/pkg/tlsutil"
21
22
"io"
22
23
"io/ioutil"
23
24
"path/filepath"
@@ -34,6 +35,7 @@ type Options struct {
34
35
ServerName string `mapstructure:"server_name"` // only for client-side TLS config
35
36
ClientCAPath string `mapstructure:"client_ca"` // only for server-side TLS config for client auth
36
37
SkipHostVerify bool `mapstructure:"skip_host_verify"`
38
+ Ciphers string `mapstructure:"ciphers"`
37
39
certWatcher * certWatcher `mapstructure:"-"`
38
40
}
39
41
@@ -52,6 +54,17 @@ func (p *Options) Config(logger *zap.Logger) (*tls.Config, error) {
52
54
ServerName : p .ServerName ,
53
55
InsecureSkipVerify : p .SkipHostVerify ,
54
56
}
57
+ if len (p .Ciphers ) > 0 {
58
+ cs := make ([]uint16 , len (p .Ciphers ))
59
+ for i , s := range p .Ciphers {
60
+ var ok bool
61
+ cs [i ], ok = tlsutil .GetCipherSuite (p .Ciphers )
62
+ if ! ok {
63
+ return nil , fmt .Errorf ("unexpected TLS cipher suite %q" , s )
64
+ }
65
+ }
66
+ tlsCfg .CipherSuites = cs
67
+ }
55
68
if p .ClientCAPath != "" {
56
69
certPool := x509 .NewCertPool ()
57
70
if err := addCertToPool (p .ClientCAPath , certPool ); err != nil {
0 commit comments