Skip to content

Commit

Permalink
[FAB-2895] Fix TLS Certificate location
Browse files Browse the repository at this point in the history
Change-Id: Ibdd60f703f8fc7ebc098786872bb18d65f2afb9b
Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com>
  • Loading branch information
fqutishat committed Mar 27, 2017
1 parent f171bef commit 405b815
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"strconv"
"strings"

"github.com/op/go-logging"
"github.com/spf13/viper"
Expand Down Expand Up @@ -148,7 +148,7 @@ func GetPeersConfig() []PeerConfig {
panic(fmt.Sprintf("tls.certificate not exist or empty for %s", key))
}

p.TLSCertificate = path.Join(os.Getenv("GOPATH"), p.TLSCertificate)
p.TLSCertificate = strings.Replace(p.TLSCertificate, "$GOPATH", os.Getenv("GOPATH"), -1)
peersConfig = append(peersConfig, p)
}
return peersConfig
Expand Down Expand Up @@ -213,7 +213,7 @@ func GetOrdererTLSServerHostOverride() string {

// GetOrdererTLSCertificate ...
func GetOrdererTLSCertificate() string {
return path.Join(os.Getenv("GOPATH"), myViper.GetString("client.orderer.tls.certificate"))
return strings.Replace(myViper.GetString("client.orderer.tls.certificate"), "$GOPATH", os.Getenv("GOPATH"), -1)
}

// GetFabricCAID ...
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestMultipleVipers(t *testing.T) {
t.Fatalf("Expected testValue before config initialization got: %s", testValue1)
}
// initialize go sdk
err = InitConfig("../integration_test/test_resources/config/config_test.yaml")
err = InitConfig("../test/fixtures/config/config_test.yaml")
if err != nil {
fmt.Println(err.Error())
}
Expand All @@ -79,7 +79,7 @@ func TestMultipleVipers(t *testing.T) {
}

func TestMain(m *testing.M) {
err := InitConfig("../integration_test/test_resources/config/config_test.yaml")
err := InitConfig("../test/fixtures/config/config_test.yaml")
if err != nil {
fmt.Println(err.Error())
}
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/config/config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ client:
event_host: "localhost"
event_port: 7053
tls:
# certificate location relative path the system will env variable $GOPATH
certificate: "src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/peers/peer0/ca-cert.pem"
# Certificate location absolute path
certificate: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/peers/peer0/ca-cert.pem"
serverHostOverride: "peer0"

peer2:
Expand All @@ -16,8 +16,8 @@ client:
event_host: "localhost"
event_port: 7058
tls:
# certificate location relative path the system will env variable $GOPATH
certificate: "src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/peers/peer1/ca-cert.pem"
# Certificate location absolute path
certificate: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/peers/peer1/ca-cert.pem"
serverHostOverride: "peer1"

tls:
Expand All @@ -36,8 +36,8 @@ client:
host: "localhost"
port: 7050
tls:
# certificate location relative path the system will env variable $GOPATH
certificate: "src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/orderer/ca-cert.pem"
# Certificate location absolute path
certificate: "$GOPATH/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/tls/orderer/ca-cert.pem"
serverHostOverride: "orderer0"

logging:
Expand Down

0 comments on commit 405b815

Please sign in to comment.