Search code examples
javassljakarta-maillotus-dominosslhandshakeexception

Same code, different behaviour in sending email through Lotus Domino


I'm trying to send an email on port 465 with SSL. Running in a stand-alone application in Eclipse, everything works well. Running in a Domino Java Agent I'm getting an SSLHandshakeException. Below you can see the code and SSLHandshakeException.

Lotus Domino Release 8.5.1 FP5

Can you help me understand what's the problem?

    private static final Object SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

    public static void main(String[] args) {
        final String username="username";
        final String password="password";
        Properties prop=new Properties();
        prop.put("mail.smtp.auth", "true");
        prop.put("mail.smtp.host", "xxx");
        prop.put("mail.debug", new Boolean("true").toString()); 
        prop.put("mail.smtp.port", "465");
        prop.put("mail.smtp.ssl.enable", "true");
        prop.put("mail.smtp.starttls.enable", "false");
        prop.put("mail.smtp.socketFactory.fallback", "false");
        prop.put("mail.smtp.socketFactory.class", SSL_FACTORY); 

        Session session = Session.getDefaultInstance(prop,
                new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });
        try {
            String htmlBody = "<strong>TEST</strong>";
            String textBody = "This is a Text Message.";
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("[email protected]"));
            message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("[email protected]"));
            message.setSubject("Testing Subject");
            MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
            mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
            mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
            mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
            mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
            mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
            CommandMap.setDefaultCommandMap(mc);
            message.setText(htmlBody);
            message.setContent(textBody, "text/html");
            Transport.send(message);

            System.out.println("Done");

        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }

Running in a Domino Java Agent I got this error:

javax.mail.MessagingException: Exception reading response;   nested  
   exception is:  javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.g:  
   Violated path length constraints
   at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1462)
   at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1260)
   at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
   at javax.mail.Service.connect(Service.java:297)
   at javax.mail.Service.connect(Service.java:156)
   at javax.mail.Service.connect(Service.java:105)
   at javax.mail.Transport.send0(Transport.java:168)
   at javax.mail.Transport.send(Transport.java:98)
   at JavaAgent.NotesMain(JavaAgent.java:60)
   at lotus.domino.AgentBase.runNotes(Unknown Source)
   at lotus.domino.NotesThread.run(Unknown Source)
   Caused by: 
     javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.g: Violated path   length constraints
   at com.ibm.jsse2.n.a(n.java:36)
   at com.ibm.jsse2.sc.a(sc.java:154)
   at com.ibm.jsse2.gb.a(gb.java:89)
   at com.ibm.jsse2.gb.a(gb.java:283)
   at com.ibm.jsse2.hb.a(hb.java:260)
   at com.ibm.jsse2.hb.a(hb.java:171)
   at com.ibm.jsse2.gb.n(gb.java:140)
   at com.ibm.jsse2.gb.a(gb.java:123)
   at com.ibm.jsse2.sc.a(sc.java:320)
   at com.ibm.jsse2.sc.g(sc.java:198)
   at com.ibm.jsse2.sc.a(sc.java:478)
   at com.ibm.jsse2.e.read(e.java:7)
   at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97)
   at java.io.BufferedInputStream.fill(BufferedInputStream.java:229)
   at java.io.BufferedInputStream.read(BufferedInputStream.java:248)
   at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:75)
   at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1440)

Solution

  • According to this is possible to turn off SSL check.

    Restart Domino server after the first send (that will fail, but will disable SSL)

    Thanks Richard