crossminer / scava

https://eclipse.org/scava/
Eclipse Public License 2.0
18 stars 13 forks source link

Getting an error when trying to get recommendation #414

Closed phkrief closed 4 years ago

phkrief commented 4 years ago

When I "Request API documentation and Q&A posts" I get an error

Unexpected error happened eclipse.buildId=4.13.0.I20190916-1045 java.version=1.8.0_66 java.vendor=Oracle Corporation BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US Framework arguments: -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.java.product Command-line arguments: -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.java.product -data file:/Users/philippe/Documents/workspaces-photon/crossminer-demonstrator4/ -product org.eclipse.epp.package.java.product

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 sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153) at org.eclipse.scava.plugin.webreferenceviewer.reference.sites.StackOverflowReferenceModel.getContent(StackOverflowReferenceModel.java:128) at org.eclipse.scava.plugin.webreferenceviewer.reference.sites.StackOverflowReferenceModel.requestItems(StackOverflowReferenceModel.java:113) at org.eclipse.scava.plugin.webreferenceviewer.reference.sites.StackOverflowReferenceModel.lambda$0(StackOverflowReferenceModel.java:46) at java.lang.Thread.run(Thread.java:745) 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:387) at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292) at sun.security.validator.Validator.validate(Validator.java:260) at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324) at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229) at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491) ... 14 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146) at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131) at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382) ... 20 more

phkrief commented 4 years ago

Folks, We made some investigations. It seems to be a certificate issue when accessing to the KB. In my understanding, 1- either we ask our user to add a missing certificate into his JVM and, in this case, please send me the certificate I have to add to my cacerts file. 2- or try to fix it in the code of the plugin.

IMHO, the second option is the best one. Now, I don't mind testing the first one to be sure this will fix the issue. WDYT?

Thanks a lot for your support

PS: Putting it as a high priority because I cannot progress on this aspect, unfortunately.

phkrief commented 4 years ago

Adding my investigations to keep track of that:

ear Endre

I got the same result from my browser. {"items":[{"owner":{"reputation":208653,"user_id":260990,"user_type":"registered","accept_rate":81,"profile_image":"https://www.gravatar.com/avatar/39acb52ff074bc477f0325f4b1960c90?s=128&d=identicon&r=PG","display_name":"Jigar Joshi","link":"https://stackoverflow.com/users/260990/jigar-joshi"},"is_accepted":true,"score":6,"last_activity_date":1423723667,"creation_date":1423723667,"answer_id":28471052,"question_id":28471025}],"has_more":false,"quota_max":300,"quota_remaining":283} So, I tried to read this URL from a java app: public class Test {

public static void main(String[] args) throws IOException {

URL url = new URL("https://api.stackexchange.com/2.2/answers/28471052?site=stackoverflow");

InputStream in = url.openStream();

Reader reader = new InputStreamReader(in);

int c = reader.read();

while (c != -1) {

    System.out.print((char)c);

    c = reader.read();

}

}

}

And I got a similar error ! Exception in thread "main" 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 sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) at java.net.URL.openStream(URL.java:1038) at Test.main(Test.java:15) 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:387) at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292) at sun.security.validator.Validator.validate(Validator.java:260) at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324) at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229) at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491) ... 14 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146) at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131) at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382) ... 20 more

Kind regards

phkrief commented 4 years ago

Any update on this issue @phkrief @gertom ? Thanks alot

phkrief commented 4 years ago

Any update, folks? I'm stuck with this error and cannot move forward.

Thanks a lot for your help

phkrief commented 4 years ago

FYI, obviously, I got the same error with the OW2 instance (http://scava-dev.ow2.org). It confirms that the issue must be solved on the client.

Thanks

gertom commented 4 years ago

@phkrief We've tried, but could not reproduce the problem. As you got the same error with a separate java app, the error seems to be in your underlying system, not in the plug-in.

phkrief commented 4 years ago

Dear @gertom , This is not really an error, this is an issue with the StackOverflow certificate. IMHO, your code should be able to avoid it. In the meantime, I try the other option: add the missing certificate. It is not straightforward because I need to find the "famous" certificate :-)

Actually, I'm working on it today. I will keep you posted Thanks

phkrief commented 4 years ago

Dear ALL I could fix this issue. I followed this suggestion: http://magicmonster.com/kb/prg/java/ssl/pkix_path_building_failed.html and added the certificate attached to this comment. So, I do confirm this is a certificate issue and it should be fixed in the plugin and not by the end-user. Kind regards

stackexchange-2.crt.zip