且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Javamail - 无法连接到SMTP主机

更新时间:2022-11-06 22:37:17

您可能想尝试下载证书,使用keytool进行安装,然后将其设置为系统变量:

You might want to try downloading the certificate, install it using keytool, then set them as system variables. Here's how:


  1. 转到Firefox浏览器中的URL,点击HTTPS证书链(URL地址旁边),点击 更多信息>security>show certificate>details>export ..。选择名称并选择文件类型示例。 $>
  2. 找到文件 $ JAVA_HOME / jre / lib,然后将其添加到您的JVM中/ security / cacerts

  3. example.der 文件导入 cacerts 文件使用以下内容:

  1. Go to URL in your firefox browser, click on HTTPS certificate chain (next to URL address). Click "more info" > "security" > "show certificate" > "details" > "export..". Pickup the name and choose file type example.der. Now you have file with keystore and you have to add it to your JVM
  2. Locate the file $JAVA_HOME/jre/lib/security/cacerts
  3. Import the example.der file into the cacerts file using the following:

sudo keytool -import -alias example -keystore  $JAVA_HOME/jre/lib/security/cacerts -file example.der


  • 默认的密钥库密码是' changeit '

    您可以查看更改th在您使用此命令显示证书指纹时。

    You can view the change that you made with this command that shows the Certificate fingerprint.

    keytool -list -keystore cacerts
    


  • 如果这不能解决问题,请尝试添加这些java选项作为参数:

  • If this doesn't solve the problem, try adding these java options as arguments:

    -Djavax.net.ssl.trustStore="$JAVA_HOME/jre/lib/security/cacerts"
    -Djavax.net.ssl.trustStorePassword="changeit"
    


  • p>

  • Or you can put them in as system variables in your java code:

    System.setProperty("javax.net.ssl.trustStore","/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre/lib/security/cacerts");
    System.setProperty("javax.net.ssl.trustStorePassword","changeit");
    


  • 可以在这里找到更多的说明: https://***.com/a/36427118/1696153

    More instructions can be found here: https://***.com/a/36427118/1696153