how to ignore server cert error in javamail

后端 未结 10 1330
长发绾君心
长发绾君心 2020-12-05 07:12

when i connect to my imap server using imaps,it failes.

can you tell me how to ignore server cert error in javamail

Exception in thread \"main\"
java         


        
10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 08:09

         Properties propsSSL = new Properties();
         propsSSL.put("mail.transport.protocol", "smtps");
         propsSSL.put("mail.smtps.host", "hostname");
         propsSSL.put("mail.smtps.auth", "true");
         propsSSL.put("mail.smtps.ssl.checkserveridentity", "false");
         propsSSL.put("mail.smtps.ssl.trust", "*");
    

    Above changes will fix javax.mail.MessagingException: Could not connect to SMTP host: hostname, port: 465; for the nested exception

    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
    exception 
    

提交回复
热议问题