How to validate SMTP server's SSL/TLS certificate using java mail API? -


we adding functionality send email through smtp. basically, when user tries add , save smtp server details through ui, need validate server's certificate. "sending mail" code done; there enough number of examples :) however, i'm trying see if there way certificate details smtp server , validate @ client side using java mail api; can see transport.connect() method implicitly validates server certificate,but i'm trying understand if there explicit way of doing it. in short, these 2 things i'm trying achieve:

1) sll/tls certificate server , prompt user relevant details(like, whether certificate valid). 2) if certificate not valid, provide option add key store.

any hints done through java mail api appreciated.

you can use openssl server certificates ssl/tls or starttls.

for ssl/tls:

openssl s_client -connect smtp.gmail.com:465 -capath /etc/ssl/ </dev/null 

for starttls:

openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587 -capath /etc/ssl/ </dev/null 

i don't know how using java mail api, perhaps can use openssl wrapper java execute calls equivalent in command lines above.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -