Secure and non secure email connections

Discussion in 'Java' started by verbal kint, Sep 4, 2004.

  1. verbal kint

    verbal kint Guest

    Hi all,

    I am currently working on a email reading program.
    I have set up two different email accounts, one that requires a SSL
    connection to the server, one that doesnot.

    I have two properties file that I load depending on whether the email
    account requires an SSL connection or not.

    The SSL properties file looks like the following:
    -------------------------------------------------------------------
    mail.imap.port=993
    mail.pop3.socketFactory.port=995
    mail.imap.socketFactory.class=javax.net.ssl.SSLSocketFactory
    mail.imap.socketFactory.port=993
    mail.pop3.socketFactory.fallback=false
    mail.imap.socketFactory.fallback=false
    mail.pop3.port=995
    mail.pop3.socketFactory.class=javax.net.ssl.SSLSocketFactory
    -------------------------------------------------------------------

    The non SSL properties file is empty

    I execute the following code for each account:

    Session session = Session.getDefaultInstance(props, null);
    System.out.println(props.getProperty("mail.imap.socketFactory.class"));
    Store store = session.getStore(serverType);
    store.connect(server, username, password); // ----------- line that
    causes the problem

    When the first account is connecting, it is working regardless of
    whether it is the SSL or non SSL account.
    However the second one crashes.
    If it is the SSL one, it just won't connect
    If it is the non SSL one, I get the following error:
    javax.mail.MessagingException:
    sun.security.validator.ValidatorException: No trusted certificate
    found;

    I print the "mail.imap.socketFactory.class" property and I do get the
    right property during the execution depending on the account.
    I am very puzzled ... Any help will be greatly appreciated!
    Thanks!
     
    verbal kint, Sep 4, 2004
    #1
    1. Advertising

  2. verbal kint

    Sudsy Guest

    verbal kint wrote:
    <snip>
    > Session session = Session.getDefaultInstance(props, null);

    <snip>
    > I print the "mail.imap.socketFactory.class" property and I do get the
    > right property during the execution depending on the account.
    > I am very puzzled ... Any help will be greatly appreciated!
    > Thanks!


    I seem to recall having some difficulties with this in the past.
    So I pulled up the javadocs and found this in the getDefaultInstance
    description:
    "Since the default session is potentially available to all code
    executing in the same Java virtual machine, ..."
    Perhaps the correct way to approach the problem is to use getInstance
    for each server. Store them in a container of your choice to facilitate
    re-use.
     
    Sudsy, Sep 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. A.M
    Replies:
    5
    Views:
    5,474
    Teemu Keiski
    Jun 8, 2004
  2. zdrakec
    Replies:
    1
    Views:
    444
    zdrakec
    Jul 25, 2005
  3. Joe
    Replies:
    5
    Views:
    975
    Steven Cheng[MSFT]
    Dec 13, 2005
  4. rb

    secure and non-secure pages

    rb, Dec 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    335
  5. Baiju

    Secure and Non-Secure Items

    Baiju, Feb 20, 2005, in forum: ASP .Net Security
    Replies:
    3
    Views:
    133
    Baiju
    Feb 23, 2005
Loading...

Share This Page