Issue #3425 - Upgrade conscrypt version to 2.0.0 and remove usage of reflection.

Small fixes after review.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2019-03-15 09:19:16 +01:00
parent 7404cce052
commit 123918018e
4 changed files with 46 additions and 60 deletions

View File

@ -90,6 +90,8 @@ public class ConscryptClientALPNProcessor implements ALPNProcessor.Client
{
SSLEngine sslEngine = alpnConnection.getSSLEngine();
String protocol = Conscrypt.getApplicationProtocol(sslEngine);
if (LOG.isDebugEnabled())
LOG.debug("Selected {} for {}", protocol, alpnConnection);
alpnConnection.selected(protocol);
}
catch (Throwable e)

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.alpn.conscrypt.server;
import java.security.Security;
import java.util.List;
import java.util.function.BiFunction;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket;
@ -74,7 +73,7 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
}
}
private final class ALPNCallback extends ApplicationProtocolSelector implements BiFunction<SSLEngine,List<String>,String>, SslHandshakeListener
private final class ALPNCallback extends ApplicationProtocolSelector implements SslHandshakeListener
{
private final ALPNServerConnection alpnConnection;
@ -88,7 +87,11 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
@Override
public String selectApplicationProtocol(SSLEngine engine, List<String> protocols)
{
return apply(engine, protocols);
alpnConnection.select(protocols);
String protocol = alpnConnection.getProtocol();
if (LOG.isDebugEnabled())
LOG.debug("Selected {} among {} for {}", protocol, protocols, alpnConnection);
return protocol;
}
@Override
@ -97,15 +100,6 @@ public class ConscryptServerALPNProcessor implements ALPNProcessor.Server
throw new UnsupportedOperationException();
}
@Override
public String apply(SSLEngine engine, List<String> protocols)
{
if (LOG.isDebugEnabled())
LOG.debug("apply {} {}", alpnConnection, protocols);
alpnConnection.select(protocols);
return alpnConnection.getProtocol();
}
@Override
public void handshakeSucceeded(Event event)
{

View File

@ -18,6 +18,14 @@
package org.eclipse.jetty.alpn.conscrypt.server;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.Security;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.conscrypt.OpenSSLProvider;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.client.HttpClient;
@ -39,15 +47,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.Security;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
@ -55,14 +54,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
public class ConscryptHTTP2ServerTest
{
Server server = new Server();
static
{
Security.addProvider(new OpenSSLProvider());
}
private Server server = new Server();
private SslContextFactory newSslContextFactory()
{
Path path = Paths.get("src", "test", "resources");
@ -77,7 +75,7 @@ public class ConscryptHTTP2ServerTest
sslContextFactory.setEndpointIdentificationAlgorithm(null);
if (JavaVersion.VERSION.getPlatform() < 9)
{
// conscrypt enable TLSv1.3 per default but it's not supported in jdk8
// Conscrypt enables TLSv1.3 by default but it's not supported in Java 8.
sslContextFactory.addExcludeProtocols("TLSv1.3");
}
return sslContextFactory;
@ -86,7 +84,6 @@ public class ConscryptHTTP2ServerTest
@BeforeEach
public void startServer() throws Exception
{
HttpConfiguration httpsConfig = new HttpConfiguration();
httpsConfig.setSecureScheme("https");
@ -107,7 +104,7 @@ public class ConscryptHTTP2ServerTest
server.setHandler(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
{
response.setStatus(200);
baseRequest.setHandled(true);
@ -115,23 +112,18 @@ public class ConscryptHTTP2ServerTest
});
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
if (server != null)
{
server.stop();
}
}
@Test
public void test_simple_query() throws Exception
public void testSimpleRequest() throws Exception
{
HTTP2Client h2Client = new HTTP2Client();
HttpClient client = new HttpClient(new HttpClientTransportOverHTTP2(h2Client), newSslContextFactory());
client.start();
@ -145,6 +137,5 @@ public class ConscryptHTTP2ServerTest
{
client.stop();
}
}
}

View File

@ -148,7 +148,7 @@ public class TestJettyOSGiBootHTTP2Conscrypt
sslContextFactory.setEndpointIdentificationAlgorithm(null);
if (JavaVersion.VERSION.getPlatform() < 9)
{
// conscrypt enable TLSv1.3 per default but it's not supported in jdk8
// Conscrypt enables TLSv1.3 by default but it's not supported in Java 8.
sslContextFactory.addExcludeProtocols("TLSv1.3");
}
HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory);
@ -160,7 +160,6 @@ public class TestJettyOSGiBootHTTP2Conscrypt
ContentResponse response = httpClient.GET("https://localhost:" + port + "/jsp/jstl.jsp");
assertEquals(200, response.getStatus());
assertTrue(response.getContentAsString().contains("JSTL Example"));
}
finally
{