导入证书后出现Java Keytool错误,“keytool error:java.io.FileNotFoundException&访问被拒绝“ [英] Java Keytool error after importing certificate , "keytool error: java.io.FileNotFoundException & Access Denied"

查看:754
本文介绍了导入证书后出现Java Keytool错误,“keytool error:java.io.FileNotFoundException&访问被拒绝“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过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:


  1. 我将HTTPS URL复制到浏览器中,下载了SSL证书&使用Internet Explorer将它们安装在浏览器中。

  1. 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\to\my\keystore\cacerts.file -file C:\path\of\exportedCert.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:


    信任此证书?

    Trust this certificate?

    我回答是。

    显示的cmd提示


    证书已添加到密钥库

    Certificate was added to keystore

    但是在该消息之后,显示了另一个异常:

    However after that message, another exception was displayed:

    keytool error: java.io.FileNotFoundException: C:\Program files\...\cacerts <Access Denied>
    


  • 最后,当我检查密钥库时,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&amp;访问被拒绝“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆