Last active
August 29, 2015 14:20
-
-
Save ujhelyiz/296feaecd87db2478016 to your computer and use it in GitHub Desktop.
SSL issue in Eclipse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import java.io.DataInputStream; | |
import java.io.IOException; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.net.URLConnection; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Map.Entry; | |
import org.junit.Test; | |
public class SSLTEST { | |
@Test | |
public void main() { | |
try { | |
URL url = new URL("https://static.incquerylabs.com/test.txt"); | |
URLConnection connection = null; | |
try { | |
connection = url.openConnection(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
Map<String, List<String>> fields = connection.getHeaderFields(); | |
Iterator<Entry<String, List<String>>> headerIterator = fields.entrySet().iterator(); | |
System.out.println("HEADERS"); | |
System.out.println("-------------------------------"); | |
while (headerIterator.hasNext()){ | |
Entry<String, List<String>> header = headerIterator.next(); | |
System.out.println(header.getKey()+" :"); | |
Iterator<String> valueIterator = header.getValue().iterator(); | |
while (valueIterator.hasNext()){ | |
System.out.println("\t"+valueIterator.next()); | |
} | |
} | |
String inputLine; | |
DataInputStream input = new DataInputStream(connection.getInputStream()); | |
System.out.println("BODY CONTENT"); | |
System.out.println("-------------------------------"); | |
while ((inputLine = input.readLine()) != null) { | |
System.out.println(inputLine); | |
} | |
} catch (MalformedURLException e) { | |
System.err.println(e); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HEADERS | |
------------------------------- | |
null : | |
HTTP/1.1 200 OK | |
ETag : | |
"9-51554f0c25dc1" | |
Date : | |
Tue, 05 May 2015 16:11:12 GMT | |
Content-Length : | |
9 | |
Last-Modified : | |
Tue, 05 May 2015 12:37:24 GMT | |
Keep-Alive : | |
timeout=5, max=100 | |
Accept-Ranges : | |
bytes | |
Connection : | |
Keep-Alive | |
Content-Type : | |
text/plain | |
Server : | |
Apache/2.4.7 (Ubuntu) | |
BODY CONTENT | |
------------------------------- | |
contents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) | |
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) | |
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) | |
at java.lang.reflect.Constructor.newInstance(Constructor.java:422) | |
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1889) | |
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1884) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1883) | |
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1456) | |
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440) | |
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) | |
at test.SSLTEST.main(SSLTEST.java:42) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:497) | |
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) | |
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) | |
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) | |
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) | |
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) | |
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) | |
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) | |
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) | |
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) | |
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) | |
at org.junit.runners.ParentRunner.run(ParentRunner.java:309) | |
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) | |
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) | |
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62) | |
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:497) | |
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587) | |
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198) | |
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) | |
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) | |
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380) | |
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:497) | |
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648) | |
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603) | |
at org.eclipse.equinox.launcher.Main.run(Main.java:1465) | |
at org.eclipse.equinox.launcher.Main.main(Main.java:1438) | |
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 sun.security.ssl.Alerts.getSSLException(Alerts.java:192) | |
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937) | |
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:1478) | |
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212) | |
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:1050) | |
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363) | |
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391) | |
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375) | |
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563) | |
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) | |
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1512) | |
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440) | |
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:2965) | |
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderFields(HttpsURLConnectionImpl.java:283) | |
at test.SSLTEST.main(SSLTEST.java:27) | |
... 42 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: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:1460) | |
... 56 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:145) | |
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) | |
... 62 more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment