gpt4 book ai didi

java - keytool 错误 : java. io.FileNotFoundException : node0. cer(没有这样的文件或目录)

转载 作者:行者123 更新时间:2023-11-30 10:12:56 26 4
gpt4 key购买 nike

我想在 cassandra 中为客户端到节点加密的开发准备服务器证书,但在运行命令时遇到以下问题:

我正在按照这些链接进行设置:

https://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/secureSSLClientToNode.html https://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/secureSSLCertificates.html

当我运行以下命令时:

keytool -export -alias cassandra -file node0.cer -keystore cassandra.keystore

我收到这个错误:

keytool error: java.lang.Exception: Keystore file does not exist: cassandra.keystore

当运行以下命令时:

keytool -import -v -trustcacerts -alias node0 -file node0.cer -keystore truststore.node0

出现此错误:

keytool error: java.io.FileNotFoundException: node0.cer (No such file or directory) java.io.FileNotFoundException: node0.cer (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.security.tools.keytool.Main.doCommands(Main.java:1037)
at sun.security.tools.keytool.Main.run(Main.java:368)
at sun.security.tools.keytool.Main.main(Main.java:361)

我的操作系统是 RS-Centos-7。

有人可以帮忙吗?

最佳答案

我假设您在生成 key 后尝试将证书的公共(public)部分导出到一个单独的文件。

所以对于第一个命令

keytool -export -alias cassandra -file node0.cer -keystore cassandra.keystore

-keystore 参数将获取使用命令创建的 keystore

keytool -genkey -keyalg RSA -alias node0 -validity 36500 -keystore keystore.node0

这是 keystore.node0

第二个错误是正常的,因为你在上一步没有生成node0.cer文件。

进一步说明:

第一步是生成 key 并将其保存到 keystore 中。这是通过

keytool -genkey -keyalg RSA -alias node0 -validity 36500 -keystore keystore.node0

此命令生成一个私钥/公钥对,并使用别名 node0 将其保存到 keystore keystore.node0 中。

第二个命令是 keytool -export -alias cassandra -file node0.cer -keystore cassandra.keystore

应该导出一个证书,但是里面有一些错误的参数。 正确的命令(与上述命令相关)是:

keytool -export -alias node0 -file node0.cer -keystore keystore.node0

在这个之后你应该有一个你可以进一步使用的 node0.cer。

基本上,为了在 Cassandra 节点之间启用 SSL,您需要执行以下操作:

  • 为您的每个节点创建一个包含私钥-公钥对的 keystore
  • 为集群中的每个节点创建一个包含证书的信任库
  • 更改每个节点上的 cassandra.yaml 文件,以便为该节点和信任库指定 keystore 。
  • 重启 Cassandra 。

为简单起见,您可以拥有包含集群中所有节点的所有证书的相同信任库。

关于java - keytool 错误 : java. io.FileNotFoundException : node0. cer(没有这样的文件或目录),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51614279/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com