UPDATE 1/26/2015 -- It appears the most recent JRE/JDK for Java 8 (update >= 31) and JRE/JDK for Java 7 now include the Godaddy G2 CA server in the default trust store. If possible, it urged you upgrade your JRE/JDK to the latest Java 8 update to resolve this issue.
UPDATE 11/29/2014 - This is still a problem, and Godaddy does not seem to care and will do nothing about it. There is a blog from Godaddy VP of Security Products from a few months ago, saying that the fix was on it and provided temporary work, but today nothing has changed. It is important to note that the Godaddy G2 CA server has been around for about 5 years, and at that time Godaddy did not take the right steps to solve this known problem. A workaround is just a workaround, not a solution. Third-party service users have zero control over how the certificate is installed on the server.
It seems users should avoid purchasing Godaddy SSL certs until they get serious about being a CA.
Here is their contact information for the SSL command if you want to call:
GoDaddy SSL Team Support Number: 1-480-505-8852 -- Email: ra@godaddy.com
UPDATE 9/17/2014 - This is still a problem, and Godaddy does not seem to care and will do nothing about it. Come back in November, when Google devalues all SHA-1 certificates, this will become a serious problem. I highly recommend anyone who can contact Godaddy and list them here.
~
tl;dr; - final update with current solution/workaround at the bottom of this post (it is a GoDaddy problem and there is a workaround until they fix it)
I have a mail server from which I am trying to send mail through my Java application. I can successfully send port 25, so I know that the code works and that's it, but 25 is not an encrypted session. I need to use TLS on port 587, which requires an SSL certificate. I have a valid SSL certificate on a server that is signed by GoDaddy G2 CA and has been working for a long time (no problem).
My problem, I get the famous PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target error message PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target when trying to connect and send mail to 587.
From my understanding of many SO links, as well as the usual google-fu, this usually happens when Java does not trust the certificate or CA - as is usually the case with a self-signed certificate. I used several online SSL Cert certificates to make sure the chain is valid, etc. Everything looks fine ... but java will not use the certificate automatically.
I know that there is a class file somewhere from Sun that will download and install the certificate in the local keystore so that java trusts it ... but it is not only impractical for an application to be deployed on several systems, but it is just silly for a signed Godaddy certificate.
What's happening? How can I get java to use a valid certificate on the server without making java accept all certificates?
EDIT: I just looked through my Java Control Panel (standard jdk 7 installation) and, of course, in the Signer CA section the message is listed: The Go Daddy Group, Inc. Go Daddy Class 2 Certification Authority The Go Daddy Group, Inc. Go Daddy Class 2 Certification Authority ... so what? My certificate is Godaddy certificate ...
UPDATE --
Here the certificate chain, as seen from the openssl command, is recommended in the comments:
~]# openssl s_client -connect smtp.somecompany.com:587 -starttls smtp CONNECTED(00000003) depth=2 C = US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com, Inc.", CN = Go Daddy Root Certificate Authority - G2 verify error:num=19:self signed certificate in certificate chain verify return:0 --- Certificate chain 0 s:/OU=Domain Control Validated/CN=smtp.somecompany.com i:/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http:
Regards, I think ...
UPDATE 2 --
Well, thanks to @Bruno, I was able to determine that my chain was corrupted - I connected the server again, and now my chain looks like that:
~]# openssl s_client -connect smtp.somecompany.com:587 -starttls smtp CONNECTED(00000003) depth=2 C = US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com, Inc.", CN = Go Daddy Root Certificate Authority - G2 verify error:num=19:self signed certificate in certificate chain verify return:0 --- Certificate chain 0 s:/OU=Domain Control Validated/CN=smtp.somecompany.com i:/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http:
Which looks better than before. - Java still raises the same exception with respect to cert path, etc. So it looks like the default G2 certificate chain is not trusted in the default java 7 keystore.
FINAL UPDATE FOR COMPLETENESS @ 1/14/2014
Just like the update - this is really a GoDaddy problem (I had long letters of support with them). They have two CA servers, one of which is called Class 2 CA , and the other is G2 CA Their Class 2 CA signs all SHA-1 certificates, and G2 CA signs all its SHA-2 certificates. This is the problem - GoDaddy has not added its new G2 CA server to the default java trust store, which is why the default java settings do not trust it with authority and, therefore, do not trust your chain certificate. Workaround until GoDaddy adds the G2 CA server to the default trust store, simply asks for your certificate using SHA-1 as to get a certificate signed by the Class 2 CA server. Rekeying is free for GoDaddy customers until your certificate expires (obviously).