dom41
dom41

Reputation: 21

OAuth2 Authentication to Gmail throws SunCertPathBuilderException/SSLHandshakeException

In my app i authenticate to Gmail using the OAuth2Authenticator from this Google example to receive Emails via Imap.

The code works perfect, but the last days some users reported an error that occurs when they try to connect to Gmail.

sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source) at java.security.cert.CertPathBuilder.build(Unknown Source) Caused: sun.security.validator.ValidatorException: PKIX path building failed at sun.security.validator.PKIXValidator.doBuild(Unknown Source) at sun.security.validator.PKIXValidator.engineValidate(Unknown Source) at sun.security.validator.Validator.validate(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) Caused: javax.net.ssl.SSLHandshakeException at sun.security.ssl.Alerts.getSSLException(Unknown Source) at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) at sun.security.ssl.Handshaker.processLoop(Unknown Source) at sun.security.ssl.Handshaker.process_record(Unknown Source) at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)

The ImapSSLStore conncets to "imap.gmail.com" on port 993.

This does not happen to all users and occurs not before last week.

Is anybody observing this behaviour too? Hints appreciated!

Upvotes: 1

Views: 243

Answers (1)

Jan Kundrát
Jan Kundrát

Reputation: 3816

Looks like your system's X.509 configuration for verifying the SSL certificates is not treating the Google's certificate as a trusted one. This might have various reasons.

Upvotes: 1

Related Questions