Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Secure and non secure email connections

Reply
Thread Tools

Secure and non secure email connections

 
 
verbal kint
Guest
Posts: n/a
 
      09-04-2004
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.SSLSoc ketFactory
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.SSLSoc ketFactory
-------------------------------------------------------------------

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.so cketFactory.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!

 
Reply With Quote
 
 
 
 
Sudsy
Guest
Posts: n/a
 
      09-04-2004
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Secure your digital information assets with Secure Auditor and alsoSecure Windows with Secure Auditor alannis.albert@googlemail.com Wireless Networking 0 04-14-2008 06:37 AM
Share session between secure and non-secure applications Joe ASP .Net 5 12-13-2005 01:49 PM
Secure and non-secure message, revisited zdrakec ASP .Net 1 07-25-2005 03:16 PM
Secure and non secure warnings KerplunKuK Computer Support 8 08-24-2004 06:41 PM
This page contains both secure and non secure items. A.M ASP .Net 5 06-08-2004 05:43 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57