Created
June 4, 2019 23:25
-
-
Save YutaHiguchi-bsn/c76dfd60ac4c2c711fcaddbf6b267f3b to your computer and use it in GitHub Desktop.
EOFException on certificate error
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
import static org.hamcrest.Matchers.instanceOf; | |
import static org.hamcrest.Matchers.not; | |
import static org.junit.Assert.assertThat; | |
import java.io.EOFException; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.atomic.AtomicReference; | |
import org.eclipse.jetty.client.HttpClient; | |
import org.eclipse.jetty.http.HttpMethod; | |
import org.eclipse.jetty.util.ssl.SslContextFactory; | |
import org.junit.Test; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class Minimum { | |
private static final Logger logger = LoggerFactory.getLogger(Minimum.class); | |
@Test | |
public void sslErrorHidden() throws Exception { | |
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client(false); | |
HttpClient jetty; | |
jetty = new HttpClient(sslContextFactory); | |
jetty.start(); | |
String someSelfSignedHttpsServer = "https://...."; | |
CountDownLatch latch = new CountDownLatch(1); | |
AtomicReference<Throwable> error = new AtomicReference<>(); | |
jetty.newRequest(someSelfSignedHttpsServer) | |
.method(HttpMethod.POST) | |
.send(result -> { | |
if (result.isFailed()) { | |
logger.error("send: ", result.getFailure()); | |
error.set(result.getFailure()); | |
} | |
latch.countDown(); | |
}); | |
latch.await(); | |
assertThat(error.get(), not(instanceOf(EOFException.class))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running above result in following log from listener registered at
send(..)
Failure retrieved at listener is an EOFException and it's not possible to determine if the error was certificate error or not.
If I increase the log level of
org.eclipse.jetty.io
to DEBUG, I see log about SSLHandshakeException.Is there a way to retrieve them from the client?