mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-26 11:35:10 +00:00
Enable chaincode to work without TLS as well
1. Root certificate is an optional parameter supplied for chaincode to verify the peer's connection in response. 2. If TLS is enabled, then specify the key and cert parameters. Do not expect it otherwise. Signed-off-by: S m, Aruna <arun.s.m.cse@gmail.com>
This commit is contained in:
parent
f9d458e9ae
commit
f6a06340fc
1 changed files with 18 additions and 10 deletions
|
|
@ -243,19 +243,27 @@ func getTLSProperties() shim.TLSProperties {
|
||||||
|
|
||||||
// convert tlsDisabledStr to boolean
|
// convert tlsDisabledStr to boolean
|
||||||
tlsDisabled := getBoolOrDefault(tlsDisabledStr, false)
|
tlsDisabled := getBoolOrDefault(tlsDisabledStr, false)
|
||||||
|
var keyBytes, certBytes, clientCACertBytes []byte
|
||||||
|
var err error
|
||||||
|
|
||||||
keyBytes, err := ioutil.ReadFile(key)
|
if !tlsDisabled {
|
||||||
|
keyBytes, err = ioutil.ReadFile(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("error while reading the crypto file: %s", err)
|
log.Panicf("error while reading the crypto file: %s", err)
|
||||||
}
|
}
|
||||||
certBytes, err := ioutil.ReadFile(cert)
|
certBytes, err = ioutil.ReadFile(cert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("error while reading the crypto file: %s", err)
|
log.Panicf("error while reading the crypto file: %s", err)
|
||||||
}
|
}
|
||||||
clientCACertBytes, err := ioutil.ReadFile(clientCACert)
|
}
|
||||||
|
// Did not request for the peer cert verification
|
||||||
|
if clientCACert != "" {
|
||||||
|
clientCACertBytes, err = ioutil.ReadFile(clientCACert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("error while reading the crypto file: %s", err)
|
log.Panicf("error while reading the crypto file: %s", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return shim.TLSProperties{
|
return shim.TLSProperties{
|
||||||
Disabled: tlsDisabled,
|
Disabled: tlsDisabled,
|
||||||
Key: keyBytes,
|
Key: keyBytes,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue