web3sdk icon indicating copy to clipboard operation
web3sdk copied to clipboard

FISCO-BCOS中client.keystore 的生成方法

Open fisco-dev opened this issue 6 years ago • 7 comments

FISCO-BCOS中client.keystore 的生成方法 1、client.keystore是用做web3sdk的SSL证书。 2、在web3sdk V1.0.0中,client.keystore里面有两个证书,一个client证书,一个ca证书。client.keystore的密码必须为“123456”,keystore中有私钥的client证书的密码也必须为“123456”。

V1.0.0版本的client.keystore生成方式:

(1)keytool -import -trustcacerts -alias ca -file ca.crt -keystore client.keystore
(2)openssl pkcs12 -export -name client -in server.crt -inkey server.key -out keystore.p12
(3)keytool -importkeystore -destkeystore client.keystore -srckeystore keystore.p12 -srcstoretype pkcs12 -alias client
(4)、Attention! Password must be ”123456”

注意:其中用到的ca.crt,必须是节点的ca.crt。server.crt,server.key 必须是节点的或者节点的兄弟证书(同一CA颁发)。

3、在web3sdk V1.1.0中,我们修改了证书这块的缺陷,client.keystore只保存client证书,而且命名和密码都做成了可配置。 相关的配置是这样的:

<bean class="org.bcos.channel.handler.ChannelConnections">
	<property name="caCertPath" value="classpath:ca.crt" />
	<property name="clientKeystorePath" value="classpath:client.keystore" />
	<property name="keystorePassWord" value="123456" />
	<property name="clientCertPassWord" value="123456" />
	<property name="connectionsStr">
		<list>
			<value>[email protected]:8822</value>
		</list>
	</property>
</bean>

V1.1.0版本的client.keystore生成方式:

(1)openssl pkcs12 -export -name client -in server.crt -inkey server.key -out keystore.p12
(2)keytool -importkeystore -destkeystore client.keystore -srckeystore keystore.p12 -srcstoretype pkcs12 -alias client

注意:server.crt,server.key 必须是节点的或者节点的兄弟证书(同一CA颁发)。

附录 常用的keystore命令:https://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html keystore 和 openssl整合的命令: http://www.herongyang.com/crypto/Migrating_Keys_keytool_to_OpenSSL_4.html

fisco-dev avatar Mar 28 '18 11:03 fisco-dev

V1.3.0版本的client.keystore生成方式 在V1.3.0中的sdk的client.keystore生成可以参考https://github.com/FISCO-BCOS/FISCO-BCOS/tree/master-1.3/cert中的sdk.sh

fisco-dev avatar Jun 20 '18 06:06 fisco-dev

在depotsample和evidencesample中使用的web3sdk是V1.0.0版本需要 keytool -import -noprompt -trustcacerts -alias ca -file ca.crt -keystore client.keystore

mingzhenliu avatar Jun 29 '18 04:06 mingzhenliu

sdk.sh 中的这条命令“keytool -importkeystore -destkeystore client.keystore -srckeystore keystore.p12 -srcstoretype pkcs12 -alias client”,能生成client.keystore?

skybluues avatar Jul 12 '18 06:07 skybluues

可以的

mingzhenliu avatar Jul 12 '18 06:07 mingzhenliu

我运行脚本后,只生成了ca.crt\keystore.p12和其他一些已sdk开头的文件,是哪里出问题了吗

skybluues avatar Jul 12 '18 06:07 skybluues

单独执行下,看看报了什么错误。

mingzhenliu avatar Jul 12 '18 06:07 mingzhenliu

keystore.p12 是有密码的 你在import的时候需要先输入keystore.p12的密码,然后为client.keystore设置一个密码

mingzhenliu avatar Jul 12 '18 07:07 mingzhenliu