smtp with certificates
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   steve_inca
Posted On:   Wednesday, January 15, 2003 01:14 PM

Hi Everyone, The SMTP server I need to send mail from requires authentication through a certificate and user/password. I've tried many different things and based on what I've read I think the solution should go along the lines of ... - In the main class the following is included (among other things) Security.addProvider( new com.sun.net.ssl.internal.ssl.Provider()); props.put("mail.smtp.host", host); props.put("mail.smtp.auth", "true"); props.put("mail.transport.protocol","smtp"); props.put("mail.smtp.socketFactory.class", "DummySSLSocketFactory");    More>>

Hi Everyone,



The SMTP server I need to send mail from requires authentication through a certificate and user/password.



I've tried many different things and based on what I've read I think the solution should go along the lines of ...



- In the main class the following is included (among other things)



			
Security.addProvider( new com.sun.net.ssl.internal.ssl.Provider());

props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
props.put("mail.transport.protocol","smtp");
props.put("mail.smtp.socketFactory.class", "DummySSLSocketFactory");

Session session = Session.getInstance(props,auth); // auth is an instance of a custom authentication task

//MESSAGE BUILT HERE

Transport tr = session.getTransport("smtp"); // also tried without params
tr.connect();
message.saveChanges();
tr.sendMessage(message, message.getAllRecipients());
tr.close();





For the transport class I've tried using the static method send and other combinations, using SMTPTransport directly, URLNames etc.



The relevant part of the DummySSLSocketFactory class is loading the cert.



			
CertificateFactory cf = CertificateFactory.getInstance("X.509");
KeyStore ks = KeyStore.getInstance("JKS");
tmf = TrustManagerFactory.getInstance("SunX509");
ks.load(null, null);
java.security.cert.X509Certificate cert =
(java.security.cert.X509Certificate) cf.generateCertificate(new
FileInputStream("XXX.cer"));
ks.setCertificateEntry(cert.getSubjectDN().getName(),cert);
tmf.init(ks);




I get an error indicating 'Relaying is denied'. The init code in the socket class is running fine.




I'm able to send email using the cert in other email clients such as outlook and netscape mail.




If someone could tell me whether I'm on the right track I'd really appreciate it.




Thanks!    <<Less
About | Sitemap | Contact