使用 keytool 导入证书时,为什么要使用 trustcacerts 选项
keytool -import -trustcacerts
我对 keytool 的这个 trustcacerts
选项感到困惑。
当我用谷歌搜索时,我发现了以下几点:
根据具体情况,您可能不需要
-trustcacerts
选项。如果您愿意,请尝试不使用它的操作。-trustcacerts
参数告诉 keytool 您要将其作为可信证书导入。使用 cacerts 文件从已签署要导入的证书的证书颁发机构获取受信任的证书。
最后我发现这个trustcacerts是可选的。
一般来说,网站的任何开发人员/首席执行官都希望他们的网站受到客户的信任,那么为什么我们需要使用 keytool 命令明确指定这一点呢?
谢谢
keytool -import -trustcacerts
I am confused with this trustcacerts
option of keytool.
When I googled on this, I found these points:
Depending on the situation you may not require the
-trustcacerts
option. Try the operation without it if you like.The
-trustcacerts
argument tells keytool that you want to import this as a trusted certificate.Use the cacerts file to obtain trusted certificates from certificate authorities that have signed the certificate that is being imported.
At last I found out that this trustcacerts
is optional.
Generally any Developer/CEO of the website wants that their site to be trusted by the Customers, then why do we need to explicitly specify this with the keytool command?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您导入自签名根证书以外的证书(例如中间证书)时,
keytool
首先尝试构建并验证正确的证书路径。如果您使用
trustcacerts
参数,则在构建路径时,keytool
不仅会考虑信任存储中已包含的证书,还会额外考虑cacerts
密钥存储(此文件位于 JRE 安装的 lib/security 文件夹中)。 cacerts 中的证书是一种默认信任列表,即官方信任的根证书(类似于浏览器默认信任的列表)。该选项并不是真正必要的,因为您始终可以强制导入证书。导入自签名根证书时也没有任何意义,因为在这种情况下无法构建证书路径 - 您要么信任根,要么不信任。
但如果您知道导入的证书应由 cacerts 中包含的证书之一颁发,这可能是一个不错的功能 - 如果仍然无法构建和验证整个证书路径,
keytool
会警告您 -这很可能是一个警告,表明您尝试导入的证书有问题。When you import a certificate other than a self-signed root certificate (e.g. intermediate certificates),
keytool
tries to build and validate a proper certificate path first.If you use the
trustcacerts
parameter, then for building the path,keytool
will not only consider the certificates already contained in the trust store, but it will additionally consider the certificates contained in thecacerts
key store (this file is located in the lib/security folder of your JRE installation). The certificates incacerts
are a kind of default trust list, the officially trusted root certificates (similar to the lists your browser trusts by default).The option is not really necessary since you can always force the import for a certificate. It also makes no sense when importing a self-signed root certificate, because no certificate path can be built in this situation - you either trust a root or you don't.
But it may be a nice feature if you know that the imported certificate should be issued by one of the certificates contained in cacerts -
keytool
would warn you if it still could not build and validate an entire certificate path - which would most likely be a warning that something is not right with the certificate you tried to import.