I have a problem connecting to a SMTP Server with Apache Commons Mail. I have tried everything but the only thing I can find online is for Java Mail.
This is my error:
Caused by: javax.mail.MessagingException: Could not convert socket to TLS;
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
I have seen that you can fix the issue on Java Mail with props.put("mail.smtp.ssl.trust", "smtp.gmail.com"); for example, but I can't a equivalent command to use on Apache Commons.
If you're really connecting to Gmail, you shouldn't need that. The Gmail certificate will be trusted by the default trust store. If you've configured a non-default trust store, add the Gmail certificate to that trust store using the InstallCert program.
Related
I am trying to write a program for connecting LDAP server using java code..
Connection Type - SSL
I am getting SSLHandshakeException which says I will have to use 'server certificate' to establish ssl connection -
javax.naming.CommunicationException: :636 [Root exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target]
Could anyone please suggest how to download SSL certificate from the server using java code and then use that certificate while connecting to LDAP ?
Here are the solutions i have tried, but i did not work -
How to read a Certificate attribute (caCertificate) from LDAP server (Java)?
How to make a call, via Java, with ssl and certificate to an ldap (AD)?
NOTE - I cannot override functionality of certificate verification/validation using custom socket factory
After applying the latest Windows Updates I'm getting an:
Error 500--Internal Server Error
trying to access my URL using HTTP (not HTTPS!) protocol.
Looking in Weblogic logs, I found this error:
ServletContext#199346236[app:analytics module:analytics path:/analytics spec-version:2.5 version:11.1.1]] Root cause of ServletException.
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
How can I solve this issue?
I don't know where I can find this expired certificate and if this is the real problem because I'm not using an HTTPS protocol trying to access my site.
You will have to find the location of your certificates first or your certificates are located in your keystore. If so, you can display content of your keystore and check which certificates you have.
Do you use Weblogic in combination with OSB? If yes, then the keystore is propably configured in your Enterprise Manager. If not, then your keystore is configured on Weblogic level which can be found at servers -> keystores tab
I don't know if this is the solution but let's try it out.
I'm trying to find how I can allow only for specific host to be trusted in Apache HttpClient java.
I connect to the server using Apache HttpClient via https. The server has self-signed certificates, hence I keep getting the following error :
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
Read more: https://javarevisited.blogspot.com/2016/12/javaxnetsslsslhandshakeexception-pkix-path-building-failed-certificate-not-found.html#ixzz6avX9hNiJ.
I know that we can skip certification verification for all hosts (we can trust all hosts and certifications), but my question is how can we disable certification or trust only for single specific host I want? I need to it all programatically.
I know there are a lot of question regarding the same thing on SO, but I don't seem to have found the solution for my problem yet.
I am using JavaMail API to connect to a mail server. Initially I used the port 110 to connect to pop3 server and that is when I got the following exception -
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
I changed the port to 995 and got the following exception -
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Code for connecting to the server:
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "pop3");
props.setProperty("mail.pop3.ssl.enable", "true");
Session session = Session.getInstance(props, null);
store = session.getStore("pop3");
store.connect(ServerName, Port, UserName, Password);
Where am I going wrong? Any advice would be helpful. Thanks in advance.
The first error message says it all. You're attempting SSL to a plaintext port. Try disabling SSL, or use the correct port for SSL.
The second one says that your truststore doesn't trust the server certificate. If it's self-signed, you will need to import it into your truststore.
How to send mail using gmail from IBM Websphere Application Server 7 using javamail 1.4 api without using a certificate? I either get
javax.mail.MessagingException:
Exception reading response; nested
exception is:
javax.net.ssl.SSLHandshakeException:
com.ibm.jsse2.util.g: PKIX path
building failed:
java.security.cert.CertPathBuilderException:
PKIXCertPathBuilderImpl could not
build a valid CertPath.; internal
cause is:
java.security.cert.CertPathValidatorException:
The certificate issued by OU=Equifax
Secure Certificate Authority,
O=Equifax, C=US is not trusted;
internal cause is:
java.security.cert.CertPathValidatorException:
Certificate chaining error
or
Must issue a STARTTLS command first
javamail
The same application works fine if I run it inside a main function in a java application. I have configured WAS mail sessions. Can someone please provide a working logic for the application and configuration in WAS for that?