Skip to content

Commit

Permalink
#104: use TLS certificates in flex
Browse files Browse the repository at this point in the history
  • Loading branch information
Lior Tamari committed Sep 27, 2017
1 parent 94ec806 commit 83b4ad9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions remote/client_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/IBM/ubiquity/utils/logs"
)

const keyUseSsl = "UBIQUITY_PLUGIN_USE_SSL"
const keyVerifyCA = "UBIQUITY_PLUGIN_VERIFY_CA"
const KeyUseSsl = "UBIQUITY_PLUGIN_USE_SSL"
const KeyVerifyCA = "UBIQUITY_PLUGIN_VERIFY_CA"
const storageAPIURL = "%s://%s:%d/ubiquity_storage"

func NewRemoteClient(logger *log.Logger, storageApiURL string, config resources.UbiquityPluginConfig) (resources.StorageClient, error) {
Expand All @@ -53,7 +53,7 @@ func (s *remoteClient) initialize() error {
protocol := s.getProtocol()
s.storageApiURL = fmt.Sprintf(storageAPIURL, protocol, s.config.UbiquityServer.Address, s.config.UbiquityServer.Port)
s.httpClient = &http.Client{}
verifyFileCA := os.Getenv(keyVerifyCA)
verifyFileCA := os.Getenv(KeyVerifyCA)
if verifyFileCA != "" {
if _, err := exec.Stat(verifyFileCA); err != nil {
return logger.ErrorRet(err, "failed")
Expand All @@ -75,7 +75,7 @@ func (s *remoteClient) initialize() error {
}

func (s *remoteClient) getProtocol() string {
useSsl := os.Getenv(keyUseSsl)
useSsl := os.Getenv(KeyUseSsl)
if strings.ToLower(useSsl) == "true" {
return "https"
} else {
Expand Down
6 changes: 6 additions & 0 deletions resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type UbiquityPluginConfig struct {
Backends []string
LogLevel string
CredentialInfo CredentialInfo
SslConfig UbiquityPluginSslConfig
}

type UbiquityDockerPluginConfig struct {
Expand All @@ -122,6 +123,11 @@ type ScbeRemoteConfig struct {
SkipRescanISCSI bool
}

type UbiquityPluginSslConfig struct {
UseSsl bool
VerifyCa string
}

//go:generate counterfeiter -o ../fakes/fake_storage_client.go . StorageClient

type StorageClient interface {
Expand Down

0 comments on commit 83b4ad9

Please sign in to comment.