Skip to content

Commit

Permalink
Cleaup core.yaml security section
Browse files Browse the repository at this point in the history
This change-set removes the unused properties from
the security section of core.yaml
Among other things, SHA2 is now default in core.yaml

Change-Id: I45b28c05e6c799c3ac6531f1e5d482be6f96a0a2
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
  • Loading branch information
adecaro committed Jan 6, 2017
1 parent 4ad8f9e commit e63662a
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 999 deletions.
14 changes: 7 additions & 7 deletions core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f := "init"
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")

spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}}

cccid1 := NewCCContext(chainID, "example02", "0", "", false, nil)

Expand All @@ -399,7 +399,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f = "init"
args = util.ToChaincodeArgs(f, "sum", "0")

spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}

cccid2 := NewCCContext(chainID, "example05", "0", "", false, nil)

Expand All @@ -417,7 +417,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f = "invoke"
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")

spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
var retVal []byte
_, _, retVal, err = invoke(ctxt, chainID, spec2)
Expand All @@ -440,7 +440,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
f = "query"
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")

spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
_, _, retVal, err = invoke(ctxt, chainID, spec2)

Expand Down Expand Up @@ -687,7 +687,7 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
f := "init"
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")

spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}}

cccid1 := NewCCContext(chainID, "example02", "0", "", false, nil)

Expand All @@ -711,7 +711,7 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
f = "init"
args = util.ToChaincodeArgs(f, "e", "0")

spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}

cccid2 := NewCCContext(chainID, "example04", "0", "", false, nil)

Expand All @@ -733,7 +733,7 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
cid := spec1.ChaincodeID.Name
args = util.ToChaincodeArgs(f, cid, "e", "1")

spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}, SecureContext: user}
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
// Invoke chaincode
var uuid string
_, uuid, _, err = invoke(ctxt, chainID, spec2)
Expand Down
7 changes: 2 additions & 5 deletions core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ limitations under the License.

package core

import (
"github.com/op/go-logging"
"github.com/spf13/viper"
)
import "github.com/op/go-logging"

// See fabric/core/peer/config.go for comments on the configuration caching
// methodology.
Expand All @@ -32,7 +29,7 @@ var securityEnabled bool
// CacheConfiguration caches configuration settings so that reading the yaml
// file can be avoided on future requests
func CacheConfiguration() error {
securityEnabled = viper.GetBool("security.enabled")
securityEnabled = true
configurationCached = true
return nil
}
Expand Down
14 changes: 4 additions & 10 deletions core/endorser/endorser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,10 @@ func initPeer(chainID string) (net.Listener, error) {
}

// Install security object for peer
if viper.GetBool("security.enabled") {
//TODO: integrate new crypto / idp
securityLevel := viper.GetInt("security.level")
hashAlgorithm := viper.GetString("security.hashAlgorithm")
primitives.SetSecurityLevel(hashAlgorithm, securityLevel)
} else {
// the primitives need to be instantiated no matter what. Otherwise
// the escc code won't have a hash algorithm available to hash the proposal
primitives.SetSecurityLevel("SHA2", 256)
}
//TODO: integrate new crypto / idp
securityLevel := viper.GetInt("security.level")
hashAlgorithm := viper.GetString("security.hashAlgorithm")
primitives.SetSecurityLevel(hashAlgorithm, securityLevel)

ccStartupTimeout := time.Duration(30000) * time.Millisecond
pb.RegisterChaincodeSupportServer(grpcServer, chaincode.NewChaincodeSupport(getPeerEndpoint, false, ccStartupTimeout))
Expand Down
2 changes: 1 addition & 1 deletion core/peer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func CacheConfiguration() (err error) {
syncBlocksChannelSize = viper.GetInt("peer.sync.blocks.channelSize")
validatorEnabled = viper.GetBool("peer.validator.enabled")

securityEnabled = viper.GetBool("security.enabled")
securityEnabled = true

configurationCached = true

Expand Down
4 changes: 1 addition & 3 deletions docs/Setup/Chaincode-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ Running the above commands builds and runs the CA server with the default setup,

### Running the validating peer

**Note:** To run with security enabled, first modify the [core.yaml](https://github.com/hyperledger/fabric/blob/master/peer/core.yaml) configuration file to set the `security.enabled` value to `true` before building the peer executable. Alternatively, you can enable security by running the peer with the following environment variable: `CORE_SECURITY_ENABLED=true`. To enable privacy and confidentiality of transactions (which requires security to also be enabled), modify the [core.yaml](https://github.com/hyperledger/fabric/blob/master/peer/core.yaml) configuration file to set the `security.privacy` value to `true` as well. Alternatively, you can enable privacy by running the peer with the following environment variable: `CORE_SECURITY_PRIVACY=true`. If you are enabling security and privacy on the peer process with environment variables, it is important to include these environment variables in the command when executing all subsequent peer operations (e.g. deploy, invoke, or query).

In a **new** terminal window, from the `devenv` subdirectory of your fabric workspace environment, `ssh` into Vagrant:

```
cd $GOPATH/src/github.com/hyperledger/fabric/devenv
vagrant ssh
```

Build and run the peer process to enable security and privacy after setting `security.enabled` and `security.privacy` settings to `true`.
Build and run the peer process.

```
cd $GOPATH/src/github.com/hyperledger/fabric
Expand Down
94 changes: 0 additions & 94 deletions examples/chaincode/go/asset_management/app/README.md

This file was deleted.

0 comments on commit e63662a

Please sign in to comment.