Java Keytool error after importing certificate , quot;keytool error: java.io.FileNotFoundException amp; Access Deniedquot;(Java Keytool 导入证书后出错,quot;keytool error: java.io.FileNotFoundException amp;拒绝访问)
问题描述
我正在尝试通过 HTTPS 连接 Java Web API;但是,抛出异常:
I'm trying to connect a Java Web API via HTTPS; however, an exception is thrown:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException
我按照我从在线 keytool & 中学到的这些步骤进行操作.SSL 证书教程:
I followed these steps which I learned from online keytool & SSL cert tutorials:
我将 HTTPS URL 复制到浏览器中,下载了 SSL 证书 &使用 Internet Explorer 在浏览器中安装它们.
I copied the HTTPS URL into the browser, downloaded the SSL certificates & Installed them in the browser using Internet Explorer.
将证书导出到我电脑上的某个路径,证书保存为.cer
Exported the certificates to a path on my computer, the certificates were saved as .cer
使用了 keytool 的导入选项.下面的命令执行没有任何错误.
Used the keytool's import option. The command below executed without any errors.
keytool -import -alias downloadedCertAlias -keystore C:path omykeystorecacerts.file -file C:pathofexportedCert.cer
在命令提示符处提示我输入密码,然后我输入了密码,然后我通过了身份验证.
I was prompted for a password at the command prompt, which I entered then I was authenticated.
cmd
窗口打印了一些证书数据&签名,我被提示了一个问题:
The cmd
window printed some certificate data & signatures and I was prompted with the question:
信任此证书?
我回答是.
显示的cmd提示符
证书已添加到密钥库
但是在那条消息之后,显示了另一个异常:
However after that message, another exception was displayed:
keytool error: java.io.FileNotFoundException: C:Program files...cacerts <Access Denied>
最后,当我检查 keystore 时,没有添加 SSL 证书,我的应用程序给出了与我之前尝试连接时相同的异常:
Finally when I checked the keystore , the SSL certificate was not added and my application gives the same exception I was getting earlier when trying to connect:
(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException)
推荐答案
如果您没有在管理员模式下运行命令提示符,可能会发生这种情况.如果您使用的是 Windows 7,则可以运行,输入 cmd 并按 Ctrl+Shift+enter.这将以管理员模式打开命令提示符.如果没有,您也可以转到开始 -> 所有程序 -> 附件 -> 右键单击命令提示符,然后单击以管理员身份运行".
This could happen if you are not running the command prompt in administrator mode. If you are using windows 7, you can go to run, type cmd and hit Ctrl+Shift+enter. This will open the command prompt in administrator mode. If not, you can also go to start -> all programs -> accessories -> right click command prompt and click 'run as administrator'.
这篇关于Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问"
基础教程推荐
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01