如何解决在 Hyperledger Fabric 中,如何使用 HSM 在客户端中设置 TLS 通信
我使用 Hyperledger Fabric V1.4 并且我正在将我的所有私钥移动到 HSM。在创建网关以使用我的合同时查看我的代码,我添加了一个 TLS 证书和一个私钥,但是需要私钥并且使用 HSM 我无法访问它,那么我如何连接到我的网关?
这是我连接到网关的方式:
const gateway = new Gateway();
const ccpPath = path.resolve(this.ccpPath);
await gateway.connect(ccpPath,{ wallet:this.wallet,identity: userId,discovery: { enabled: true,asLocalhost: this.asLocalhost } });
const client = gateway.getClient();
client.setTlsClientCertAndKey(identityUsuarioTLS.certificate,identityUsuarioTLS.privateKey);
我看到我可以添加一个 CryptoSuite,我猜我可以告诉客户端它的私钥有一个 HSM,但我不知道在哪里可以告诉客户端使用什么身份TLS 通信。
查看代码,如果我使用不带参数的 setTlsClientCertAndKey() 然后它会创建并自签名证书,但我的 HSM 中已经有了一个。
setTlsClientCertAndKey(clientCert,clientKey) {
logger.debug('setTlsClientCertAndKey - start');
if (clientCert && clientKey) {
this._tls_mutual.clientCert = clientCert;
this._tls_mutual.clientKey = clientKey;
this._tls_mutual.clientCertHash = null;
this._tls_mutual.selfGenerated = false;
} else {
if (this._userContext) {
logger.debug('setTlsClientCertAndKey - generating self-signed TLS client certificate');
// generate X509 cert pair
// use the default software cryptosuite,not the client assigned cryptosuite,which may be
// HSM,or the default has been set to HSM. FABN-830
const key = Client.newCryptoSuite({software: true}).generateEphemeralKey();
this._tls_mutual.clientKey = key.toBytes();
this._tls_mutual.clientCert = key.generateX509Certificate(this._userContext.getName());
this._tls_mutual.selfGenerated = true;
}
}
}
我还没有找到关于这方面的文档,所以任何能引导我走向正确方向的帮助都会很棒。
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。