1. <tfoot id='Qus0q'></tfoot>

      • <bdo id='Qus0q'></bdo><ul id='Qus0q'></ul>
      <i id='Qus0q'><tr id='Qus0q'><dt id='Qus0q'><q id='Qus0q'><span id='Qus0q'><b id='Qus0q'><form id='Qus0q'><ins id='Qus0q'></ins><ul id='Qus0q'></ul><sub id='Qus0q'></sub></form><legend id='Qus0q'></legend><bdo id='Qus0q'><pre id='Qus0q'><center id='Qus0q'></center></pre></bdo></b><th id='Qus0q'></th></span></q></dt></tr></i><div id='Qus0q'><tfoot id='Qus0q'></tfoot><dl id='Qus0q'><fieldset id='Qus0q'></fieldset></dl></div>
    1. <legend id='Qus0q'><style id='Qus0q'><dir id='Qus0q'><q id='Qus0q'></q></dir></style></legend>

      <small id='Qus0q'></small><noframes id='Qus0q'>

    2. 没有身份验证信任证书的 JavaMail SSL

      JavaMail SSL with no Authentication trust certificate regardless(没有身份验证信任证书的 JavaMail SSL)

            <tbody id='7loQU'></tbody>
          <tfoot id='7loQU'></tfoot>

            <legend id='7loQU'><style id='7loQU'><dir id='7loQU'><q id='7loQU'></q></dir></style></legend>
            <i id='7loQU'><tr id='7loQU'><dt id='7loQU'><q id='7loQU'><span id='7loQU'><b id='7loQU'><form id='7loQU'><ins id='7loQU'></ins><ul id='7loQU'></ul><sub id='7loQU'></sub></form><legend id='7loQU'></legend><bdo id='7loQU'><pre id='7loQU'><center id='7loQU'></center></pre></bdo></b><th id='7loQU'></th></span></q></dt></tr></i><div id='7loQU'><tfoot id='7loQU'></tfoot><dl id='7loQU'><fieldset id='7loQU'></fieldset></dl></div>
              <bdo id='7loQU'></bdo><ul id='7loQU'></ul>

              <small id='7loQU'></small><noframes id='7loQU'>

              • 本文介绍了没有身份验证信任证书的 JavaMail SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个带有 SSL(端口 465)和自签名证书的本地邮件服务器 (hMailServer).

                I have a local mail server (hMailServer) with SSL (port 465) and a self-signed certificate.

                域名是foobar.com"

                Domain is "foobar.com"

                我已设置我的 Properties 以启用 ssl、禁用身份验证并信任任何主机

                I have setup my Properties to enable ssl, disable auth, and trust any host

                    props.put("mail.smtp.auth", "false");
                    props.put("mail.smtp.ssl.enable", "true");
                    props.put("mail.smtp.ssl.trust", "*");
                

                如果我通过对 Transport.send() 的静态调用发送消息电子邮件已送达.

                If I send the message through the static call to Transport.send() The email gets delivered.

                如果我尝试从会话中获取 transport 实例,那么我会得到

                If I try to get a transport instance from the session then I get

                javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                

                静态调用如何避免 SSLHandshakeException?

                这是我的测试代码:

                public static void main(String[] args) throws Exception {
                    Properties props = new Properties();
                    props.put("mail.smtp.host", "127.0.0.1");
                    props.put("mail.debug", "false");
                    props.put("mail.smtp.port", "465");
                    props.put("mail.smtp.timeout", "60000");
                    props.put("mail.smtp.auth", "false");
                    props.put("mail.smtp.sendpartial", "true");
                    props.put("mail.smtp.ssl.enable", "true");
                    props.put("mail.smtp.ssl.trust", "*");
                    Session session = Session.getInstance(props);
                    Message message = new MimeMessage(session);
                    message.setFrom(new InternetAddress("mrFoo@foobar.com"));
                    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("you@foobar.com"));
                    message.setSubject("Just a Test " + new Date());
                    message.setText("Hello World");
                
                    //Comment and uncomment to test   
                    Transport.send(message, message.getAllRecipients());
                
                    //Transport t = session.getTransport("smtps");
                    //t.connect();
                    //t.sendMessage(message, message.getAllRecipients());
                    //t.close();
                }
                

                这是一个从外部隐藏的本地系统,所以我不担心中间人攻击生成自己的证书以绕过 SSL 握手...

                This is a local system hidden from the outside, so I am not worried about man in the middle attack generating their own certificates to bypass the SSL Handshake...

                推荐答案

                您要求smtps"传输.您设置smtp"传输的属性.由于您已将mail.smtp.ssl.enable"属性设置为true",因此您只需请求smtp"传输,它将使用 SSL.

                You asked for an "smtps" transport. You set the properties for the "smtp" transport. Since you've set the "mail.smtp.ssl.enable" property to "true", you can just ask for an "smtp" transport and it will use SSL.

                这篇关于没有身份验证信任证书的 JavaMail SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Compiling C++ for the JVM(为 JVM 编译 C++)
                Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                  <tfoot id='AUZKQ'></tfoot>
                    <tbody id='AUZKQ'></tbody>

                    <bdo id='AUZKQ'></bdo><ul id='AUZKQ'></ul>
                    • <small id='AUZKQ'></small><noframes id='AUZKQ'>

                          <legend id='AUZKQ'><style id='AUZKQ'><dir id='AUZKQ'><q id='AUZKQ'></q></dir></style></legend>
                        1. <i id='AUZKQ'><tr id='AUZKQ'><dt id='AUZKQ'><q id='AUZKQ'><span id='AUZKQ'><b id='AUZKQ'><form id='AUZKQ'><ins id='AUZKQ'></ins><ul id='AUZKQ'></ul><sub id='AUZKQ'></sub></form><legend id='AUZKQ'></legend><bdo id='AUZKQ'><pre id='AUZKQ'><center id='AUZKQ'></center></pre></bdo></b><th id='AUZKQ'></th></span></q></dt></tr></i><div id='AUZKQ'><tfoot id='AUZKQ'></tfoot><dl id='AUZKQ'><fieldset id='AUZKQ'></fieldset></dl></div>