Remove CACerts requirement

This commit is contained in:
Harshavardhana
2015-01-30 16:23:23 -08:00
parent b2fd5fd489
commit 170f9bc9c7
3 changed files with 6 additions and 19 deletions
-6
View File
@@ -29,11 +29,6 @@ func doMinioConfigure(c *cli.Context) {
log.Fatal("Invalid hostname")
}
caFile := c.String("cacert")
if caFile == "" {
log.Fatal("invalid CA file")
}
certFile := c.String("cert")
if certFile == "" {
log.Fatal("invalid certificate")
@@ -56,7 +51,6 @@ func doMinioConfigure(c *cli.Context) {
// AccessKey: accessKey,
// SecretAccessKey: secretKey,
Hostname: hostname,
CACert: caFile,
CertPEM: certFile,
KeyPEM: keyFile,
}
+1 -1
View File
@@ -122,7 +122,7 @@ var MinioConfigure = cli.Command{
Usage: "Minio access key",
},
cli.StringFlag{
Name: "SecretKey",
Name: "secretKey",
Value: "",
Usage: "Minio secret key",
},
+5 -12
View File
@@ -2,7 +2,6 @@ package minio
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
)
@@ -11,19 +10,17 @@ type Auth struct {
AccessKey string
SecretAccessKey string
Hostname string
CACert string
CertPEM string
KeyPEM string
}
type TlsConfig struct {
CABlock []byte
CertPEMBlock []byte
KeyPEMBlock []byte
}
func (a *Auth) loadKeys(cert string, key string) (*TlsConfig, error) {
caBlock, err := ioutil.ReadFile(cert)
certBlock, err := ioutil.ReadFile(cert)
if err != nil {
return nil, err
}
@@ -32,14 +29,13 @@ func (a *Auth) loadKeys(cert string, key string) (*TlsConfig, error) {
return nil, err
}
t := &TlsConfig{}
t.CABlock = caBlock
t.CertPEMBlock = caBlock
t.CertPEMBlock = certBlock
t.KeyPEMBlock = keyBlock
return t, nil
}
func (a *Auth) getTlsTransport() (*http.Transport, error) {
tlsconfig, err := a.loadKeys(a.CACert, a.KeyPEM)
tlsconfig, err := a.loadKeys(a.CertPEM, a.KeyPEM)
if err != nil {
return nil, err
}
@@ -49,13 +45,10 @@ func (a *Auth) getTlsTransport() (*http.Transport, error) {
return nil, err
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(tlsconfig.CABlock)
// Setup HTTPS client
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
Certificates: []tls.Certificate{cert},
InsecureSkipVerify: true,
}
tlsConfig.BuildNameToCertificate()