I'm trying to connect a Java Web API via HTTPS; however, an exception is thrown:

我尝试通过HTTPS连接Java Web API;但是,抛出一个异常:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException

I followed these steps which I learned from online keytool & SSL cert tutorials:

我遵循了从网上keytool & SSL cert教程中学到的步骤:

  1. I copied the HTTPS URL into the browser, downloaded the SSL certificates & Installed them in the browser using Internet Explorer.

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

  2. Exported the certificates to a path on my computer, the certificates were saved as .cer

    将证书导出到我的计算机上的路径,这些证书保存为.cer

  3. Used the keytool's import option. The command below executed without any errors.

    使用keytool的导入选项。下面的命令执行时没有任何错误。

    keytool -import -alias downloadedCertAlias -keystore C:\path\to\my\keystore\cacerts.file -file C:\path\of\exportedCert.cer
    
  4. I was prompted for a password at the command prompt, which I entered then I was authenticated.

    在命令提示符中提示输入密码,输入后我就被验证了。

  5. The cmd window printed some certificate data & signatures and I was prompted with the question:

    cmd窗口打印了一些证书数据和签名,我被提示这样一个问题:

    Trust this certificate?

    信任此证书吗?

    I answered yes.

    我回答是的。

  6. The cmd prompt displayed

    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>
    

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:

最后,当我检查keystore时,SSL证书没有被添加,我的应用程序也给出了我在尝试连接时得到的相同的异常:

(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException)

10 个解决方案

#1


190

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'.

如果您没有在管理员模式下运行命令提示符,这可能会发生。如果你正在使用windows 7,你可以去运行,输入cmd,按Ctrl+Shift+enter。这将在管理员模式下打开命令提示符。如果没有,您也可以转到start -> all program -> accessories ->右键单击命令提示符并单击“作为管理员运行”。

更多相关文章

  1. java 自制Tomcat Andorid IOS 端 证书
  2. php RSA加密 JAVA 证书生成

随机推荐

  1. android:clipChildren 子元素超出父元素
  2. android布局layout中的一些属性
  3. Android中的人脸检测的示例代码(静态和动
  4. Android 设置控件是否可见
  5. 【从源码看Android】03Android(安卓)Mess
  6. android root权限相关bin程序rageagainst
  7. Android TextView文字链接4中方法
  8. Android 导入Flutter模块
  9. android ARM 汇编学习 —— hello world
  10. android去掉系统默认标题栏