3 Replies Latest reply on Jan 6, 2009 5:59 PM by noelo

    IMAP via TLS in JBoss 4.2.2.GA

      Hi all,
      I'm just trying to connect to an IMAP mailserver from JBoss. But all I get is the following exception:

      15:07:10,484 ERROR [STDERR] javax.mail.MessagingException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target;
       nested exception is:
       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
      15:07:10,499 ERROR [STDERR] at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
      15:07:10,499 ERROR [STDERR] at javax.mail.Service.connect(Service.java:297)
      15:07:10,499 ERROR [STDERR] at javax.mail.Service.connect(Service.java:156)
      15:07:10,499 ERROR [STDERR] at javax.mail.Service.connect(Service.java:105)


      My mail-service.xml looks like following:

       <mbean code="org.jboss.mail.MailService" name="MSTM:service=OrderSMSService">
       <attribute name="JNDIName">java:/ORDERSMS
       </attribute>
       <attribute name="User">me</attribute>
       <attribute name="Password">dontknow</attribute>
       <attribute name="Configuration">
       <configuration>
       <property name="mail.transport.protocol" value="imap" />
       <property name="mail.user" value="me" />
       <property name="mail.password" value="dontknow" />
      
       <property name="mail.host" value="my.favourite.mailserver.com" />
      
       <property name="mail.smtp.host" value="my.favourite.mailserver.com" />
      
       <property name="mail.imap.starttls.enable" value="true" />
      
       <property name="mail.debug" value="true" />
       </configuration>
       </attribute>
       </mbean>
      


      To access the mailbox I'm using the following code:

      Store store = mailSession.getStore("imaps");
       store.connect();
      

      How can I tell JBoss to connect to the IMAP server?

      TIA,
      Ralf.

        • 1. Re: IMAP via TLS in JBoss 4.2.2.GA
          noelo

          I think the problem has to do with the IMAP servers SSL cert not being trusted by the JVM. A possible fix is to download the cert and add it to the JVM's cacerts file. I'm not too sure how but google will be your friend.....

          • 2. Re: IMAP via TLS in JBoss 4.2.2.GA

            I have imported the certificate from the ssl server into my jvm cacerts. But the error remains. Any ideas?

            Greetz,
            Ralf.

            • 3. Re: IMAP via TLS in JBoss 4.2.2.GA
              noelo

              No idea, but just a suggestion is the imap ssl server listening on the correct port i.e. 993 and what happens if you specify it in the options

               <property name="mail.host" value="my.favourite.mailserver.com:993" />
              
               <property name="mail.smtp.host" value="my.favourite.mailserver.com" />