我试图通过 HTTPS 连接 JavaWebAPI; 但是,抛出了一个异常:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException
我遵循了从在线 keytool 和 SSL 认证教程中学到的以下步骤:
我把 HTTPS 的网址复制到浏览器中,下载了 SSL 证书并用 Internet Explorer 安装在浏览器中。
将证书导出到我计算机上的一个路径,证书保存为 .cer
使用了 keytool 的导入选项。下面的命令执行时没有任何错误。
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.
The cmd
window printed some certificate data & signatures and I was prompted with the question:
Trust this certificate?
I answered yes.
The cmd prompt displayed
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:
(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException)