-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用openssl生成的RSA证书在console控制台上使用遇到证书加载错误 #817
Comments
Hi @liuxinfeng96 |
链版本号:2.9.1 genCert := |
首先,这个错误提示说我的私钥无效,还没到证书,其次是我用openssl解析过我的私钥是没问题的。然后,我用go语言标准库生成的密钥证书,也是报这个问题。但是,我用go的sdk加载这个密钥证书去连接节点,订阅节点是没问题的,我怀疑是java sdk这边解析密钥的时候,是不是因为编码格式不符合给拦截了 |
私钥格式应该是pkcs8,所以最后一步应该将私钥转换成pkcs8格式。详细步骤如下: openssl genrsa -out ./sdk1/sdk.key 2048
openssl req -new -sha256 -subj /CN=FISCO-BCOS/O=fisco-bcos/OU=agency -key ./sdk1/sdk.key -out ./sdk1/sdk.csr
openssl x509 -req -days 36500 -sha256 -CA /temp/nodes/cert/agency/channel/ca.crt -CAkey /temp/nodes/cert/agency/channel/ca.key -CAcreateserial -in ./sdk1/sdk.csr -out ./sdk1/sdk.crt -extensions v4_req
openssl pkcs8 -topk8 -in ./sdk1/sdk.key -out ./sdk1/pkcs8_node.key -nocrypt
mv ./sdk1/pkcs8_node.key ./sdk1/sdk.key |
好的明白了,感谢解答~ |
Java SDK目前只支持PKCS8格式的原因是,Java SDK在网络建连的时候依赖于Netty,Netty目前加载私钥时只支持PKCS8格式的私钥,详情可见链接:https://netty.io/wiki/sslcontextbuilder-and-private-key.html 理论上只要是RSA的私钥都是能支持,只是Java SDK受限于Netty使用。后续版本会考虑支持兼容PKCS1。 |
我自己使用openssl生成的RSA证书,使用go sdk开发的程序配置上此套密钥证书,并没有连接加载问题,能够正常获取链上数据和订阅区块链。但是,当我想要使用console控制台发送交易,将RSA证书密钥配置到console,启动console start脚本,出现读取密钥失败的错误,如图:
我的证书密钥:
conf.zip
The text was updated successfully, but these errors were encountered: