mirror of
https://github.com/minio/minio.git
synced 2025-01-27 06:33:18 -05:00
Fix etcd TLS handling (#6748)
etcd fails to connect if TLS config is set, make TLS conditional to input arguments instead
This commit is contained in:
parent
d9cfa5fcd3
commit
6491dfbbd6
@ -34,6 +34,7 @@ import (
|
|||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
"github.com/minio/minio/pkg/auth"
|
"github.com/minio/minio/pkg/auth"
|
||||||
"github.com/minio/minio/pkg/dns"
|
"github.com/minio/minio/pkg/dns"
|
||||||
|
xnet "github.com/minio/minio/pkg/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check for updates and print a notification message
|
// Check for updates and print a notification message
|
||||||
@ -159,27 +160,45 @@ func handleCommonEnvVars() {
|
|||||||
if ok {
|
if ok {
|
||||||
etcdEndpoints := strings.Split(etcdEndpointsEnv, ",")
|
etcdEndpoints := strings.Split(etcdEndpointsEnv, ",")
|
||||||
|
|
||||||
// This is only to support client side certificate authentication
|
var etcdSecure bool
|
||||||
// https://coreos.com/etcd/docs/latest/op-guide/security.html
|
for _, endpoint := range etcdEndpoints {
|
||||||
etcdClientCertFile, ok1 := os.LookupEnv("MINIO_ETCD_CLIENT_CERT")
|
u, err := xnet.ParseURL(endpoint)
|
||||||
etcdClientCertKey, ok2 := os.LookupEnv("MINIO_ETCD_CLIENT_CERT_KEY")
|
if err != nil {
|
||||||
var getClientCertificate func(*tls.CertificateRequestInfo) (*tls.Certificate, error)
|
logger.FatalIf(err, "Unable to initialize etcd with %s", etcdEndpoints)
|
||||||
if ok1 && ok2 {
|
|
||||||
getClientCertificate = func(unused *tls.CertificateRequestInfo) (*tls.Certificate, error) {
|
|
||||||
cert, err := tls.LoadX509KeyPair(etcdClientCertFile, etcdClientCertKey)
|
|
||||||
return &cert, err
|
|
||||||
}
|
}
|
||||||
|
// If one of the endpoint is https, we will use https directly.
|
||||||
|
etcdSecure = etcdSecure || u.Scheme == "https"
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
globalEtcdClient, err = etcd.New(etcd.Config{
|
if etcdSecure {
|
||||||
Endpoints: etcdEndpoints,
|
// This is only to support client side certificate authentication
|
||||||
DialTimeout: defaultDialTimeout,
|
// https://coreos.com/etcd/docs/latest/op-guide/security.html
|
||||||
DialKeepAliveTime: defaultDialKeepAlive,
|
etcdClientCertFile, ok1 := os.LookupEnv("MINIO_ETCD_CLIENT_CERT")
|
||||||
TLS: &tls.Config{
|
etcdClientCertKey, ok2 := os.LookupEnv("MINIO_ETCD_CLIENT_CERT_KEY")
|
||||||
RootCAs: globalRootCAs,
|
var getClientCertificate func(*tls.CertificateRequestInfo) (*tls.Certificate, error)
|
||||||
GetClientCertificate: getClientCertificate,
|
if ok1 && ok2 {
|
||||||
},
|
getClientCertificate = func(unused *tls.CertificateRequestInfo) (*tls.Certificate, error) {
|
||||||
})
|
cert, terr := tls.LoadX509KeyPair(etcdClientCertFile, etcdClientCertKey)
|
||||||
|
return &cert, terr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globalEtcdClient, err = etcd.New(etcd.Config{
|
||||||
|
Endpoints: etcdEndpoints,
|
||||||
|
DialTimeout: defaultDialTimeout,
|
||||||
|
DialKeepAliveTime: defaultDialKeepAlive,
|
||||||
|
TLS: &tls.Config{
|
||||||
|
RootCAs: globalRootCAs,
|
||||||
|
GetClientCertificate: getClientCertificate,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
globalEtcdClient, err = etcd.New(etcd.Config{
|
||||||
|
Endpoints: etcdEndpoints,
|
||||||
|
DialTimeout: defaultDialTimeout,
|
||||||
|
DialKeepAliveTime: defaultDialKeepAlive,
|
||||||
|
})
|
||||||
|
}
|
||||||
logger.FatalIf(err, "Unable to initialize etcd with %s", etcdEndpoints)
|
logger.FatalIf(err, "Unable to initialize etcd with %s", etcdEndpoints)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ export MINIO_ACCESS_KEY=aws_access_key
|
|||||||
export MINIO_SECRET_KEY=aws_secret_key
|
export MINIO_SECRET_KEY=aws_secret_key
|
||||||
export MINIO_IAM_JWKS_URL=https://localhost:9443/oauth2/jwks
|
export MINIO_IAM_JWKS_URL=https://localhost:9443/oauth2/jwks
|
||||||
export MINIO_IAM_OPA_URL=http://localhost:8181/v1/data/httpapi/authz
|
export MINIO_IAM_OPA_URL=http://localhost:8181/v1/data/httpapi/authz
|
||||||
export MINIO_ETCD_ENDPOINTS=localhost:2379
|
export MINIO_ETCD_ENDPOINTS=http://localhost:2379
|
||||||
minio gateway s3
|
minio gateway s3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ You may also setup etcd with TLS following this documentation [here](https://cor
|
|||||||
### 3. Setup Minio with etcd
|
### 3. Setup Minio with etcd
|
||||||
Minio server expects environment variable for etcd as `MINIO_ETCD_ENDPOINTS`, this environment variable takes many comma separated entries.
|
Minio server expects environment variable for etcd as `MINIO_ETCD_ENDPOINTS`, this environment variable takes many comma separated entries.
|
||||||
```
|
```
|
||||||
export MINIO_ETCD_ENDPOINTS=localhost:2379
|
export MINIO_ETCD_ENDPOINTS=http://localhost:2379
|
||||||
minio server /data
|
minio server /data
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2,4 +2,4 @@ export MINIO_ACCESS_KEY=minio
|
|||||||
export MINIO_SECRET_KEY=minio123
|
export MINIO_SECRET_KEY=minio123
|
||||||
export MINIO_IAM_JWKS_URL=http://localhost:9763/oauth2/jwks
|
export MINIO_IAM_JWKS_URL=http://localhost:9763/oauth2/jwks
|
||||||
export MINIO_IAM_OPA_URL=http://localhost:8181/v1/data/httpapi/authz
|
export MINIO_IAM_OPA_URL=http://localhost:8181/v1/data/httpapi/authz
|
||||||
export MINIO_ETCD_ENDPOINTS=localhost:2379
|
export MINIO_ETCD_ENDPOINTS=http://localhost:2379
|
||||||
|
Loading…
x
Reference in New Issue
Block a user