将 SSL 证书添加到 JRE 以访问 HTTPS 站点 [英] Adding an SSL Certificate to JRE in order to access HTTPS sites

查看:47
本文介绍了将 SSL 证书添加到 JRE 以访问 HTTPS 站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:

所以我试图从我的 Java 代码访问一个 HTTPS 站点,但由于我的本地主机和服务器之间的 SSL 握手问题,我无法访问.出现此问题的原因似乎是我尝试访问的 URL 没有由授权 CA 颁发的有效证书.

So I'm trying to access an HTTPS site from my Java code but I am not able due to an SSL Handshake issues between my localhost and the server. It seems the reason for this issues is that the URL I am trying to access has no valid certificate issued from an authorized CA.

因此,经过一些研究,我将尝试将有问题的 SSL 证书导入到我的 JRE 中,这样就可以对其进行验证.

So after some research, I'm going to try to import the offending SSL certificates into my JRE, that way it can be validated.

问题:

使用keytool导入证书的这个命令的mac等价物是什么:

What is the mac equivalent of this command using the keytool for importing certificates:

keytool -import -alias mycertificate -keystore ..libsecuritycacerts -file c:mycert.cer

参考:

http://www.jyothis.co.in/2011/11/12/javax-net-ssl-sslhandshakeexception/

任何帮助或帮助将不胜感激,谢谢

Any help or assistance would be much appreciated, thank you

推荐答案

您应该能够使用您指定的命令将服务器(自签名?)SSL 证书导入本地主机.为了更完整,您可以尝试

You should be able to import the server (self-signed?) SSL certificate onto your localhost using the command you specified. To be more complete, you can try

$JAVA_HOME/bin/keytool -import -alias mycertificate -keystore path_to_keystore -file certificate_file 

哪里

  • $JAVA_HOME 在 Mac 上是 /System/Library/Frameworks/JavaVM.framework/Home/
  • path_to_key_sotre$JAVA_HOME/lib/security/cacerts
  • certificate_file 是您存储下载的证书的位置
  • $JAVA_HOME on Mac is /System/Library/Frameworks/JavaVM.framework/Home/
  • path_to_key_sotre is $JAVA_HOME/lib/security/cacerts
  • certificate_file is where you store the downloaded certificate

如果出现提示,默认信任库密码为 changeit.

If prompted, the default truststore password is changeit.

这篇关于将 SSL 证书添加到 JRE 以访问 HTTPS 站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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