Twitter REST API got sun.security.validator.ValidatorException


#1

In our application, we’re using Twitter4j.

org.twitter4j
twitter4j-core
3.0.5


org.twitter4j
twitter4j-stream
3.0.5

This is the method we used to fetch user timeline:
private void getTweetDataByTwitterScreenName(Twitter twitter, String twitterScreenName) {
try {
List statuses = twitter.getUserTimeline(twitterScreenName);
for (Status status : statuses) {
if (!isTweetExistingInDB(status.getId())) {
saveTweet(status);
logger.info(MessageFormat.format(logMesageTemplate, twitterScreenName, String.valueOf(status.getId()), status.getText()));
}
}
} catch (TwitterException te) {
te.printStackTrace();
logger.error(“Failed to get timeline:” + te.getMessage());
emailSender.sendEmail(MAILSUBJECT, te.getMessage());
System.exit(-1);
}
}

We launched this application several months ago. It ran correctly. Since last Friday, we did get this issue. It indicates couldn’t find valid certification. I checked our configured oauth. It matches what displayed in created application. Anyone has idea on this issue? Thanks a lot!
oauth.consumerKey=S7cItjW******
oauth.consumerSecret=lSja*******
oauth.accessToken=10************
oauth.accessTokenSecret=82****

Here is the exact exception we got:

sun.security.validator.ValidatorException: PKIX path building failed: sun.securi
ty.provider.certpath.SunCertPathBuilderException: unable to find valid certifica
tion path to requested target
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=00df323f or
http://www.google.co.jp/search?q=44677343
TwitterException{exceptionCode=[00df323f-44677343 c60d4d36-4886f0e3 c60d4d36-488
6f0e3 c60d4d36-4886f0e3], statusCode=-1, message=null, code=-1, retryAfter=-1, r
ateLimitStatus=null, version=3.0.5}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:17
7)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.j
ava:61)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:
81)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1929)
at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:158)
at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:183)
at org.bcbsal.member.application.tweetsrest.TweetsRESTProcessor.getTweet
DataByTwitterScreenName(TweetsRESTProcessor.java:58)
at org.bcbsal.member.application.tweetsrest.TweetsRESTProcessor.fetchTwe
etData(TweetsRESTProcessor.java:51)
at org.bcbsal.member.application.tweetsrest.TweetsRESTMain.main(TweetsRE
STMain.java:24)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.Validator
Exception: PKIX path building failed: sun.security.provider.certpath.SunCertPath
BuilderException: unable to find valid certification path to requested target
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)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source
)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unk
nown Source)
at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl.java
:34)
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:14
1)
… 8 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find vali
d certification path to requested target
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 Sour
ce)
… 23 more
Caused by: 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)
… 29 more