Fabric SDK无法初始化cryptosuite配置

时间:2019-03-31 02:53:09

标签: go hyperledger-fabric

我正在IBM Cloud Blockchain Platform 2.0上运行业务网络。我从平台控制台的实例化智能合约部分下载了连接配置文件,并尝试使用Fabric SDK for Go进行连接,但遇到错误。

这是我当前的相关代码,位于主菜单下

configOpts := fabricConfig.FromFile("./profiles/flex.json")
fabSDK, err := fabsdk.New(configOpts)
if err != nil {
    entry.WithError(err).Fatal("Error setting up Fabric SDK")
}
defer fabSDK.Close()

预期:连接到业务网络实例

实际:我遇到了错误

FATA[0000] Error setting up Fabric SDK env=DEV 
error="failed to initialize configuration: unable to initialize cryptosuite using crypto suite config: 
failed to initialize crypto suite: Unsupported BCCSP Provider: "

1 个答案:

答案 0 :(得分:0)

我将“ cryptoconfig”路径添加到客户端。

BCCSP是可选的,您可以删除。

我添加了示例配置,请参见下文。

在Github go-SDK config.yaml上更详细的配置

{
"name": "first-network-org1",
"version": "1.0.0",
"client": {
    "organization": "Org1",
    "logging": {
        "level": "info"
    },
    "cryptoconfig": {
        "path": "crypto-config"
    },
    "credentialStore": {
        "path": "/tmp/keystore",
        "cryptoStore": {
            "path": "/tmp/msp"
        }
    },
    "connection": {
        "timeout": {
            "peer": {
                "endorser": "300"
            }
        }
    }
},
"channels": {
    "mychannel": {
        "peers": {
            "peer0.org1.example.com": {}
        }
    }
},
"orderers": {
    "orderer.example.com": {
        "url": "orderer.example.com:7050",
        "grpcOptions": {
            "ssl-target-name-override": "orderer.example.com",
            "keep-alive-time": "60s",
            "keep-alive-timeout": "60s",
            "keep-alive-permit": false,
            "fail-fast": false,
            "allow-insecure": false
        },
        "tlsCACerts": {
            "path": "crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem"
        }
    }
},
"organizations": {
    "Org1": {
        "mspid": "Org1MSP",
        "cryptoPath": "crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp",
        "peers": [
            "peer0.org1.example.com",
            "peer1.org1.example.com"
        ],
        "certificateAuthorities": [
            "ca.org1.example.com"
        ]
    }
},
"peers": {
    "peer0.org1.example.com": {
        "url": "grpcs://localhost:7051",
        "tlsCACerts": {
            "path": "crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
        },
        "grpcOptions": {
            "ssl-target-name-override": "peer0.org1.example.com"
        }
    },
    "peer1.org1.example.com": {
        "url": "grpcs://localhost:8051",
        "tlsCACerts": {
            "path": "crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
        },
        "grpcOptions": {
            "ssl-target-name-override": "peer1.org1.example.com"
        }
    }
},
"certificateAuthorities": {
    "ca.org1.example.com": {
        "url": "https://localhost:7054",
        "caName": "ca-org1",
        "tlsCACerts": {
            "path": "crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
        },
        "httpOptions": {
            "verify": false
        }
    }
}

}