Since dec 10th, connection thru jtwitter always results in error "unable to find valid certification path to requested target"

130 views
Skip to first unread message

parz...@gmail.com

unread,
Dec 17, 2013, 11:46:46 AM12/17/13
to jt...@googlegroups.com
Hello,

Since dec 10th, I cannot sent tweets thru jtwitter anymore - I just get errors with the following stacktrace:

winterwell.jtwitter.TwitterException$IO: 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
    at winterwell.jtwitter.URLConnectionHttpClient.getPage2_ex(URLConnectionHttpClient.java:294)
    at winterwell.jtwitter.URLConnectionHttpClient.post(URLConnectionHttpClient.java:369)
    at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:2762)
    at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:2694)
    at winterwell.jtwitter.Twitter.setStatus(Twitter.java:2482)
    ... 4 more
Caused by: 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
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1584)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:848)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
    at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:877)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1089)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1116)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1100)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:402)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:883)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
    at winterwell.jtwitter.OAuthSignpostClient.post2_connect(OAuthSignpostClient.java:394)
    at winterwell.jtwitter.URLConnectionHttpClient.post2(URLConnectionHttpClient.java:378)
    at winterwell.jtwitter.URLConnectionHttpClient.post(URLConnectionHttpClient.java:347)
    ... 7 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
    at sun.security.validator.Validator.validate(Validator.java:203)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)
    at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:841)
    ... 21 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)
    ... 26 more


Before dec 10th everything worked fine.
I'm using jtwitter version 2.8.8

The code:

void sendTwitter(String accessName, String accessToken, String accessTokenSecret, String message) throws TwitterException {

    OAuthSignpostClient client = new OAuthSignpostClient(
            OAuthSignpostClient.JTWITTER_OAUTH_KEY,
            OAuthSignpostClient.JTWITTER_OAUTH_SECRET,
            accessToken,
            accessTokenSecret);

    Twitter jtwit = new Twitter(accessName, client);

    jtwit.setStatus(message);
}


I found an article on twitter.com telling that api.twitter.com has changed to a new certificate on Dec 10th, 2013

https://dev.twitter.com/blog/rest-api-ssl-certificate-updates

But the information provided there doesn't really help to solve my problem.
Does anyone know how to solve this problem?

Is it maybe possible to even switch off ssl when using jtwitter?
I don't really need ssl...

Thanks for help...

parz...@gmail.com

unread,
Dec 17, 2013, 12:12:18 PM12/17/13
to jt...@googlegroups.com
Additional:

Updating to the current jtwitter version 2.9.0 didn't help to solve the problem - same error....

Daniel Winterstein

unread,
Dec 17, 2013, 12:20:26 PM12/17/13
to jt...@googlegroups.com, parz...@gmail.com
Hello Parziman,

Sorry to hear about this problem.

I am unable to reproduce it.
At SoDash, we use JTwitter a lot. There are a handful of exceptions
like this in our log files -- but they're temporary glitches which go
away when the connection is retried.

What version of Java are you using?

Could you perhaps send me a unit test including login details (ie.
access token and secret) which displays the problem?

NB: Please email this to me directly to avoid making access tokens public.

Best regards,
- Daniel
> --
> You received this message because you are subscribed to the Google Groups
> "JTwitter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jtwit+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
--------------------------------------
Dr Daniel Winterstein
Director
Edinburgh +44 (0)772 5172 612
http://winterwell.com http://sodash.com

parz...@gmail.com

unread,
Dec 17, 2013, 6:05:01 PM12/17/13
to jt...@googlegroups.com
Hello Daniel,

thanks a lot for your fast reply!

I've tried the code under Windows and under Linux Ubuntu, both with Java version 1.5.0.
Both create the same error.
Both were working before Dec 10th.

But I discovered a way, how to send messages without SSL:
Just call jtwit.setAPIRootUrl("http://api.twitter.com/1.1") on the Twitter object before jtwit.setStatus(...).
The internal default API Root Url is "https://api.twitter.com/1.1", so the mentioned setAPIRootUrl() call just switches off the SSL mode.
This works fine.

Best regards,
Philipp

parz...@gmail.com

unread,
Dec 17, 2013, 9:13:03 PM12/17/13
to jt...@googlegroups.com
Hello Daniel,

about the unit test:
I think, it wouldn't really help, since there are no problems in your environment.

And I also think, I found the cause for this problem.
After your question for the Java version, I also tried the code under Linux Ubuntu with Java version 1.6.0.
There the error doesn't show up - the code works fine.
So it's obviously a problem of the Java version.
With the new certificate, which Twitter uses since 10.12.2013, you can run the library just without SSL when using a Java version below 1.6.

Thanks a lot for your help!

Best regards,
Philipp
Reply all
Reply to author
Forward
0 new messages