Conscrypt with jdk8 to enable ALPN for http2











up vote
1
down vote

favorite












I have been searching how to implement Conscrypt SSL provider using conscrypt-openjdk-uber-1.4.1.jar for jdk8 to support ALPN for making a http2(using apache httpclient 5) connection to a server as jdk8 does not support ALPN by default or the other solution is to migrate to jdk9(or higher) which is not feasible for now as our product is heavily dependent on jdk8



I have been searching extensively for some docs or examples to implement but I could not find one.



I have tried to insert conscrypt provider as default and my program takes it as default provider but still it fails to connect with http2 server, my example is as follows,



public static void main(final String args) throws Exception {
Security.insertProviderAt(new OpenSSLProvider(), 1);
final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(new TrustAllStrategy()).build();
final PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder.create().setTlsStrategy(new H2TlsStrategy(sslContext, NoopHostnameVerifier.INSTANCE)).build();
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setSoTimeout(Timeout.ofSeconds(5)).build();
final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal(HttpVersionPolicy.FORCE_HTTP_2, H2Config.DEFAULT, null, ioReactorConfig, connectionManager);

client.start();
final HttpHost target = new HttpHost("localhost", 8082, "https");
final Future<AsyncClientEndpoint> leaseFuture = client.lease(target, null);
final AsyncClientEndpoint endpoint = leaseFuture.get(10, TimeUnit.SECONDS);
try {
String requestUris = new String {"/"};
CountDownLatch latch = new CountDownLatch(requestUris.length);
for (final String requestUri: requestUris) {
SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
endpoint.execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), new FutureCallback<SimpleHttpResponse>() {
@Override
public void completed(final SimpleHttpResponse response) {
latch.countDown();
System.out.println(requestUri + "->" + response.getCode());
System.out.println(response.getBody());
}

@Override
public void failed(final Exception ex) {
latch.countDown();
System.out.println(requestUri + "->" + ex);
ex.printStackTrace();
}

@Override
public void cancelled() {
latch.countDown();
System.out.println(requestUri + " cancelled");
}

});
}
latch.await();
} catch (Exception e) {
e.printStackTrace();
}finally {
endpoint.releaseAndReuse();
}

client.shutdown(ShutdownType.GRACEFUL);
}


this programs gives the output as




org.apache.hc.core5.http.ConnectionClosedException: Connection closed
org.apache.hc.core5.http.ConnectionClosedException: Connection closed
at org.apache.hc.core5.http2.impl.nio.FrameInputBuffer.read(FrameInputBuffer.java:146)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2StreamMultiplexer.onInput(AbstractHttp2StreamMultiplexer.java:415)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2IOEventHandler.inputReady(AbstractHttp2IOEventHandler.java:63)
at org.apache.hc.core5.http2.impl.nio.ClientHttp2IOEventHandler.inputReady(ClientHttp2IOEventHandler.java:38)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:117)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:50)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:173)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:123)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:80)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.lang.Thread.run(Thread.java:748)




If I print the provider and version it prints as Conscrypt version 1.0 and JDK 1.8.0_162, but still it fails to connect with a http2 endpoint



same chunk of code works perfectly if I connect using jdk9 with default provider, what I m missing here in conscrypt configuration?



Any help is appreciated



Thanks in advance










share|improve this question
























  • I know of Jetty working with Java 8 and Conscrypt. Jetty includes a client side library. Here is an example connecting via HTTP/2 to a server. Maybe this could be an alternative for you.
    – vanje
    Nov 20 at 10:35










  • Thanks for your suggestion, but my requirement is for apache httpclient
    – Zyber
    Nov 20 at 10:38















up vote
1
down vote

favorite












I have been searching how to implement Conscrypt SSL provider using conscrypt-openjdk-uber-1.4.1.jar for jdk8 to support ALPN for making a http2(using apache httpclient 5) connection to a server as jdk8 does not support ALPN by default or the other solution is to migrate to jdk9(or higher) which is not feasible for now as our product is heavily dependent on jdk8



I have been searching extensively for some docs or examples to implement but I could not find one.



I have tried to insert conscrypt provider as default and my program takes it as default provider but still it fails to connect with http2 server, my example is as follows,



public static void main(final String args) throws Exception {
Security.insertProviderAt(new OpenSSLProvider(), 1);
final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(new TrustAllStrategy()).build();
final PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder.create().setTlsStrategy(new H2TlsStrategy(sslContext, NoopHostnameVerifier.INSTANCE)).build();
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setSoTimeout(Timeout.ofSeconds(5)).build();
final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal(HttpVersionPolicy.FORCE_HTTP_2, H2Config.DEFAULT, null, ioReactorConfig, connectionManager);

client.start();
final HttpHost target = new HttpHost("localhost", 8082, "https");
final Future<AsyncClientEndpoint> leaseFuture = client.lease(target, null);
final AsyncClientEndpoint endpoint = leaseFuture.get(10, TimeUnit.SECONDS);
try {
String requestUris = new String {"/"};
CountDownLatch latch = new CountDownLatch(requestUris.length);
for (final String requestUri: requestUris) {
SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
endpoint.execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), new FutureCallback<SimpleHttpResponse>() {
@Override
public void completed(final SimpleHttpResponse response) {
latch.countDown();
System.out.println(requestUri + "->" + response.getCode());
System.out.println(response.getBody());
}

@Override
public void failed(final Exception ex) {
latch.countDown();
System.out.println(requestUri + "->" + ex);
ex.printStackTrace();
}

@Override
public void cancelled() {
latch.countDown();
System.out.println(requestUri + " cancelled");
}

});
}
latch.await();
} catch (Exception e) {
e.printStackTrace();
}finally {
endpoint.releaseAndReuse();
}

client.shutdown(ShutdownType.GRACEFUL);
}


this programs gives the output as




org.apache.hc.core5.http.ConnectionClosedException: Connection closed
org.apache.hc.core5.http.ConnectionClosedException: Connection closed
at org.apache.hc.core5.http2.impl.nio.FrameInputBuffer.read(FrameInputBuffer.java:146)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2StreamMultiplexer.onInput(AbstractHttp2StreamMultiplexer.java:415)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2IOEventHandler.inputReady(AbstractHttp2IOEventHandler.java:63)
at org.apache.hc.core5.http2.impl.nio.ClientHttp2IOEventHandler.inputReady(ClientHttp2IOEventHandler.java:38)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:117)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:50)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:173)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:123)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:80)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.lang.Thread.run(Thread.java:748)




If I print the provider and version it prints as Conscrypt version 1.0 and JDK 1.8.0_162, but still it fails to connect with a http2 endpoint



same chunk of code works perfectly if I connect using jdk9 with default provider, what I m missing here in conscrypt configuration?



Any help is appreciated



Thanks in advance










share|improve this question
























  • I know of Jetty working with Java 8 and Conscrypt. Jetty includes a client side library. Here is an example connecting via HTTP/2 to a server. Maybe this could be an alternative for you.
    – vanje
    Nov 20 at 10:35










  • Thanks for your suggestion, but my requirement is for apache httpclient
    – Zyber
    Nov 20 at 10:38













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have been searching how to implement Conscrypt SSL provider using conscrypt-openjdk-uber-1.4.1.jar for jdk8 to support ALPN for making a http2(using apache httpclient 5) connection to a server as jdk8 does not support ALPN by default or the other solution is to migrate to jdk9(or higher) which is not feasible for now as our product is heavily dependent on jdk8



I have been searching extensively for some docs or examples to implement but I could not find one.



I have tried to insert conscrypt provider as default and my program takes it as default provider but still it fails to connect with http2 server, my example is as follows,



public static void main(final String args) throws Exception {
Security.insertProviderAt(new OpenSSLProvider(), 1);
final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(new TrustAllStrategy()).build();
final PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder.create().setTlsStrategy(new H2TlsStrategy(sslContext, NoopHostnameVerifier.INSTANCE)).build();
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setSoTimeout(Timeout.ofSeconds(5)).build();
final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal(HttpVersionPolicy.FORCE_HTTP_2, H2Config.DEFAULT, null, ioReactorConfig, connectionManager);

client.start();
final HttpHost target = new HttpHost("localhost", 8082, "https");
final Future<AsyncClientEndpoint> leaseFuture = client.lease(target, null);
final AsyncClientEndpoint endpoint = leaseFuture.get(10, TimeUnit.SECONDS);
try {
String requestUris = new String {"/"};
CountDownLatch latch = new CountDownLatch(requestUris.length);
for (final String requestUri: requestUris) {
SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
endpoint.execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), new FutureCallback<SimpleHttpResponse>() {
@Override
public void completed(final SimpleHttpResponse response) {
latch.countDown();
System.out.println(requestUri + "->" + response.getCode());
System.out.println(response.getBody());
}

@Override
public void failed(final Exception ex) {
latch.countDown();
System.out.println(requestUri + "->" + ex);
ex.printStackTrace();
}

@Override
public void cancelled() {
latch.countDown();
System.out.println(requestUri + " cancelled");
}

});
}
latch.await();
} catch (Exception e) {
e.printStackTrace();
}finally {
endpoint.releaseAndReuse();
}

client.shutdown(ShutdownType.GRACEFUL);
}


this programs gives the output as




org.apache.hc.core5.http.ConnectionClosedException: Connection closed
org.apache.hc.core5.http.ConnectionClosedException: Connection closed
at org.apache.hc.core5.http2.impl.nio.FrameInputBuffer.read(FrameInputBuffer.java:146)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2StreamMultiplexer.onInput(AbstractHttp2StreamMultiplexer.java:415)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2IOEventHandler.inputReady(AbstractHttp2IOEventHandler.java:63)
at org.apache.hc.core5.http2.impl.nio.ClientHttp2IOEventHandler.inputReady(ClientHttp2IOEventHandler.java:38)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:117)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:50)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:173)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:123)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:80)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.lang.Thread.run(Thread.java:748)




If I print the provider and version it prints as Conscrypt version 1.0 and JDK 1.8.0_162, but still it fails to connect with a http2 endpoint



same chunk of code works perfectly if I connect using jdk9 with default provider, what I m missing here in conscrypt configuration?



Any help is appreciated



Thanks in advance










share|improve this question















I have been searching how to implement Conscrypt SSL provider using conscrypt-openjdk-uber-1.4.1.jar for jdk8 to support ALPN for making a http2(using apache httpclient 5) connection to a server as jdk8 does not support ALPN by default or the other solution is to migrate to jdk9(or higher) which is not feasible for now as our product is heavily dependent on jdk8



I have been searching extensively for some docs or examples to implement but I could not find one.



I have tried to insert conscrypt provider as default and my program takes it as default provider but still it fails to connect with http2 server, my example is as follows,



public static void main(final String args) throws Exception {
Security.insertProviderAt(new OpenSSLProvider(), 1);
final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(new TrustAllStrategy()).build();
final PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder.create().setTlsStrategy(new H2TlsStrategy(sslContext, NoopHostnameVerifier.INSTANCE)).build();
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom().setSoTimeout(Timeout.ofSeconds(5)).build();
final MinimalHttpAsyncClient client = HttpAsyncClients.createMinimal(HttpVersionPolicy.FORCE_HTTP_2, H2Config.DEFAULT, null, ioReactorConfig, connectionManager);

client.start();
final HttpHost target = new HttpHost("localhost", 8082, "https");
final Future<AsyncClientEndpoint> leaseFuture = client.lease(target, null);
final AsyncClientEndpoint endpoint = leaseFuture.get(10, TimeUnit.SECONDS);
try {
String requestUris = new String {"/"};
CountDownLatch latch = new CountDownLatch(requestUris.length);
for (final String requestUri: requestUris) {
SimpleHttpRequest request = SimpleHttpRequest.get(target, requestUri);
endpoint.execute(SimpleRequestProducer.create(request), SimpleResponseConsumer.create(), new FutureCallback<SimpleHttpResponse>() {
@Override
public void completed(final SimpleHttpResponse response) {
latch.countDown();
System.out.println(requestUri + "->" + response.getCode());
System.out.println(response.getBody());
}

@Override
public void failed(final Exception ex) {
latch.countDown();
System.out.println(requestUri + "->" + ex);
ex.printStackTrace();
}

@Override
public void cancelled() {
latch.countDown();
System.out.println(requestUri + " cancelled");
}

});
}
latch.await();
} catch (Exception e) {
e.printStackTrace();
}finally {
endpoint.releaseAndReuse();
}

client.shutdown(ShutdownType.GRACEFUL);
}


this programs gives the output as




org.apache.hc.core5.http.ConnectionClosedException: Connection closed
org.apache.hc.core5.http.ConnectionClosedException: Connection closed
at org.apache.hc.core5.http2.impl.nio.FrameInputBuffer.read(FrameInputBuffer.java:146)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2StreamMultiplexer.onInput(AbstractHttp2StreamMultiplexer.java:415)
at org.apache.hc.core5.http2.impl.nio.AbstractHttp2IOEventHandler.inputReady(AbstractHttp2IOEventHandler.java:63)
at org.apache.hc.core5.http2.impl.nio.ClientHttp2IOEventHandler.inputReady(ClientHttp2IOEventHandler.java:38)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:117)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:50)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:173)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:123)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:80)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.lang.Thread.run(Thread.java:748)




If I print the provider and version it prints as Conscrypt version 1.0 and JDK 1.8.0_162, but still it fails to connect with a http2 endpoint



same chunk of code works perfectly if I connect using jdk9 with default provider, what I m missing here in conscrypt configuration?



Any help is appreciated



Thanks in advance







java apache-httpclient-4.x http2 alpn apache-httpclient-5.x






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 6:09

























asked Nov 20 at 6:02









Zyber

5810




5810












  • I know of Jetty working with Java 8 and Conscrypt. Jetty includes a client side library. Here is an example connecting via HTTP/2 to a server. Maybe this could be an alternative for you.
    – vanje
    Nov 20 at 10:35










  • Thanks for your suggestion, but my requirement is for apache httpclient
    – Zyber
    Nov 20 at 10:38


















  • I know of Jetty working with Java 8 and Conscrypt. Jetty includes a client side library. Here is an example connecting via HTTP/2 to a server. Maybe this could be an alternative for you.
    – vanje
    Nov 20 at 10:35










  • Thanks for your suggestion, but my requirement is for apache httpclient
    – Zyber
    Nov 20 at 10:38
















I know of Jetty working with Java 8 and Conscrypt. Jetty includes a client side library. Here is an example connecting via HTTP/2 to a server. Maybe this could be an alternative for you.
– vanje
Nov 20 at 10:35




I know of Jetty working with Java 8 and Conscrypt. Jetty includes a client side library. Here is an example connecting via HTTP/2 to a server. Maybe this could be an alternative for you.
– vanje
Nov 20 at 10:35












Thanks for your suggestion, but my requirement is for apache httpclient
– Zyber
Nov 20 at 10:38




Thanks for your suggestion, but my requirement is for apache httpclient
– Zyber
Nov 20 at 10:38












1 Answer
1






active

oldest

votes

















up vote
2
down vote













Just replacing the default JSSE provider with Conscrypt is not enough. One also needs a custom TlsStrategy that can take advantage of Conscrypt APIs.



This what works for me with Java 1.8 and Conscrypt 1.4.1



static class ConscriptClientTlsStrategy implements TlsStrategy {

private final SSLContext sslContext;

public ConscriptClientTlsStrategy(final SSLContext sslContext) {
this.sslContext = Args.notNull(sslContext, "SSL context");
}

@Override
public boolean upgrade(
final TransportSecurityLayer tlsSession,
final HttpHost host,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final Object attachment) {
final String scheme = host != null ? host.getSchemeName() : null;
if (URIScheme.HTTPS.same(scheme)) {
tlsSession.startTls(
sslContext,
host,
SSLBufferMode.STATIC,
(endpoint, sslEngine) -> {
final SSLParameters sslParameters = sslEngine.getSSLParameters();
sslParameters.setProtocols(H2TlsSupport.excludeBlacklistedProtocols(sslParameters.getProtocols()));
sslParameters.setCipherSuites(H2TlsSupport.excludeBlacklistedCiphers(sslParameters.getCipherSuites()));
H2TlsSupport.setEnableRetransmissions(sslParameters, false);
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ?
(HttpVersionPolicy) attachment : HttpVersionPolicy.NEGOTIATE;
final String appProtocols;
switch (versionPolicy) {
case FORCE_HTTP_1:
appProtocols = new String { ApplicationProtocols.HTTP_1_1.id };
break;
case FORCE_HTTP_2:
appProtocols = new String { ApplicationProtocols.HTTP_2.id };
break;
default:
appProtocols = new String { ApplicationProtocols.HTTP_2.id, ApplicationProtocols.HTTP_1_1.id };
}
if (Conscrypt.isConscrypt(sslEngine)) {
sslEngine.setSSLParameters(sslParameters);
Conscrypt.setApplicationProtocols(sslEngine, appProtocols);
} else {
H2TlsSupport.setApplicationProtocols(sslParameters, appProtocols);
sslEngine.setSSLParameters(sslParameters);
}
},
(endpoint, sslEngine) -> {
if (Conscrypt.isConscrypt(sslEngine)) {
return new TlsDetails(sslEngine.getSession(), Conscrypt.getApplicationProtocol(sslEngine));
}
return null;
});
return true;
}
return false;
}

}

public static void main(String args) throws Exception {
final SSLContext sslContext = SSLContexts.custom()
.setProvider(Conscrypt.newProvider())
.build();
final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create()
.setTlsStrategy(new ConscriptClientTlsStrategy(sslContext))
.build();
try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setConnectionManager(cm)
.build()) {

client.start();

final HttpHost target = new HttpHost("nghttp2.org", 443, "https");
final String requestUri = "/httpbin";
final HttpClientContext clientContext = HttpClientContext.create();

final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
final Future<SimpleHttpResponse> future = client.execute(
SimpleRequestProducer.create(request),
SimpleResponseConsumer.create(),
clientContext,
new FutureCallback<SimpleHttpResponse>() {

@Override
public void completed(final SimpleHttpResponse response) {
System.out.println(requestUri + "->" + response.getCode() + " " +
clientContext.getProtocolVersion());
System.out.println(response.getBody());
final SSLSession sslSession = clientContext.getSSLSession();
if (sslSession != null) {
System.out.println("SSL protocol " + sslSession.getProtocol());
System.out.println("SSL cipher suite " + sslSession.getCipherSuite());
}
}

@Override
public void failed(final Exception ex) {
System.out.println(requestUri + "->" + ex);
}

@Override
public void cancelled() {
System.out.println(requestUri + " cancelled");
}

});
future.get();

System.out.println("Shutting down");
client.shutdown(CloseMode.GRACEFUL);
}
}





share|improve this answer























  • This works with few modifications, thanks for your efforts @oleg
    – Zyber
    Nov 22 at 13:11










  • @Zyber You might want to share your modifications here or with Apache HttpComponents
    – oleg
    Nov 22 at 17:58










  • the changes are mostly like typos thats why I didn't share, anyway I ll share so that it may help people like me 1. tlsSession.startTls is only accepting 4 parameters(sslcontext, SSLBufferManagement, SSLSessionInitializer, SSLSessionVerifier) it doesnt accept host as a parameter 2.second parameter in above method only accepts as SSLBufferManagement not as SSLBufferMode like in the code snippet 3.SimpleHttpRequests.GET.create(target, requestUri) can be replaced by SimpleHttpRequest.get(target, requestUri) 4.CloseMode.GRACEFUL can be replace by ShutDownType.GRACEFUL
    – Zyber
    Nov 23 at 5:34












  • And your snippet used CloseableHttpClient, I have changed it to MinimalHttpAsyncClient for multiplexing in http2
    – Zyber
    Nov 23 at 5:56










  • You are still using 5.0 BETA1. I would recommend upgrading to 5.0 BETA2
    – oleg
    Nov 23 at 8:13











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387107%2fconscrypt-with-jdk8-to-enable-alpn-for-http2%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













Just replacing the default JSSE provider with Conscrypt is not enough. One also needs a custom TlsStrategy that can take advantage of Conscrypt APIs.



This what works for me with Java 1.8 and Conscrypt 1.4.1



static class ConscriptClientTlsStrategy implements TlsStrategy {

private final SSLContext sslContext;

public ConscriptClientTlsStrategy(final SSLContext sslContext) {
this.sslContext = Args.notNull(sslContext, "SSL context");
}

@Override
public boolean upgrade(
final TransportSecurityLayer tlsSession,
final HttpHost host,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final Object attachment) {
final String scheme = host != null ? host.getSchemeName() : null;
if (URIScheme.HTTPS.same(scheme)) {
tlsSession.startTls(
sslContext,
host,
SSLBufferMode.STATIC,
(endpoint, sslEngine) -> {
final SSLParameters sslParameters = sslEngine.getSSLParameters();
sslParameters.setProtocols(H2TlsSupport.excludeBlacklistedProtocols(sslParameters.getProtocols()));
sslParameters.setCipherSuites(H2TlsSupport.excludeBlacklistedCiphers(sslParameters.getCipherSuites()));
H2TlsSupport.setEnableRetransmissions(sslParameters, false);
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ?
(HttpVersionPolicy) attachment : HttpVersionPolicy.NEGOTIATE;
final String appProtocols;
switch (versionPolicy) {
case FORCE_HTTP_1:
appProtocols = new String { ApplicationProtocols.HTTP_1_1.id };
break;
case FORCE_HTTP_2:
appProtocols = new String { ApplicationProtocols.HTTP_2.id };
break;
default:
appProtocols = new String { ApplicationProtocols.HTTP_2.id, ApplicationProtocols.HTTP_1_1.id };
}
if (Conscrypt.isConscrypt(sslEngine)) {
sslEngine.setSSLParameters(sslParameters);
Conscrypt.setApplicationProtocols(sslEngine, appProtocols);
} else {
H2TlsSupport.setApplicationProtocols(sslParameters, appProtocols);
sslEngine.setSSLParameters(sslParameters);
}
},
(endpoint, sslEngine) -> {
if (Conscrypt.isConscrypt(sslEngine)) {
return new TlsDetails(sslEngine.getSession(), Conscrypt.getApplicationProtocol(sslEngine));
}
return null;
});
return true;
}
return false;
}

}

public static void main(String args) throws Exception {
final SSLContext sslContext = SSLContexts.custom()
.setProvider(Conscrypt.newProvider())
.build();
final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create()
.setTlsStrategy(new ConscriptClientTlsStrategy(sslContext))
.build();
try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setConnectionManager(cm)
.build()) {

client.start();

final HttpHost target = new HttpHost("nghttp2.org", 443, "https");
final String requestUri = "/httpbin";
final HttpClientContext clientContext = HttpClientContext.create();

final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
final Future<SimpleHttpResponse> future = client.execute(
SimpleRequestProducer.create(request),
SimpleResponseConsumer.create(),
clientContext,
new FutureCallback<SimpleHttpResponse>() {

@Override
public void completed(final SimpleHttpResponse response) {
System.out.println(requestUri + "->" + response.getCode() + " " +
clientContext.getProtocolVersion());
System.out.println(response.getBody());
final SSLSession sslSession = clientContext.getSSLSession();
if (sslSession != null) {
System.out.println("SSL protocol " + sslSession.getProtocol());
System.out.println("SSL cipher suite " + sslSession.getCipherSuite());
}
}

@Override
public void failed(final Exception ex) {
System.out.println(requestUri + "->" + ex);
}

@Override
public void cancelled() {
System.out.println(requestUri + " cancelled");
}

});
future.get();

System.out.println("Shutting down");
client.shutdown(CloseMode.GRACEFUL);
}
}





share|improve this answer























  • This works with few modifications, thanks for your efforts @oleg
    – Zyber
    Nov 22 at 13:11










  • @Zyber You might want to share your modifications here or with Apache HttpComponents
    – oleg
    Nov 22 at 17:58










  • the changes are mostly like typos thats why I didn't share, anyway I ll share so that it may help people like me 1. tlsSession.startTls is only accepting 4 parameters(sslcontext, SSLBufferManagement, SSLSessionInitializer, SSLSessionVerifier) it doesnt accept host as a parameter 2.second parameter in above method only accepts as SSLBufferManagement not as SSLBufferMode like in the code snippet 3.SimpleHttpRequests.GET.create(target, requestUri) can be replaced by SimpleHttpRequest.get(target, requestUri) 4.CloseMode.GRACEFUL can be replace by ShutDownType.GRACEFUL
    – Zyber
    Nov 23 at 5:34












  • And your snippet used CloseableHttpClient, I have changed it to MinimalHttpAsyncClient for multiplexing in http2
    – Zyber
    Nov 23 at 5:56










  • You are still using 5.0 BETA1. I would recommend upgrading to 5.0 BETA2
    – oleg
    Nov 23 at 8:13















up vote
2
down vote













Just replacing the default JSSE provider with Conscrypt is not enough. One also needs a custom TlsStrategy that can take advantage of Conscrypt APIs.



This what works for me with Java 1.8 and Conscrypt 1.4.1



static class ConscriptClientTlsStrategy implements TlsStrategy {

private final SSLContext sslContext;

public ConscriptClientTlsStrategy(final SSLContext sslContext) {
this.sslContext = Args.notNull(sslContext, "SSL context");
}

@Override
public boolean upgrade(
final TransportSecurityLayer tlsSession,
final HttpHost host,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final Object attachment) {
final String scheme = host != null ? host.getSchemeName() : null;
if (URIScheme.HTTPS.same(scheme)) {
tlsSession.startTls(
sslContext,
host,
SSLBufferMode.STATIC,
(endpoint, sslEngine) -> {
final SSLParameters sslParameters = sslEngine.getSSLParameters();
sslParameters.setProtocols(H2TlsSupport.excludeBlacklistedProtocols(sslParameters.getProtocols()));
sslParameters.setCipherSuites(H2TlsSupport.excludeBlacklistedCiphers(sslParameters.getCipherSuites()));
H2TlsSupport.setEnableRetransmissions(sslParameters, false);
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ?
(HttpVersionPolicy) attachment : HttpVersionPolicy.NEGOTIATE;
final String appProtocols;
switch (versionPolicy) {
case FORCE_HTTP_1:
appProtocols = new String { ApplicationProtocols.HTTP_1_1.id };
break;
case FORCE_HTTP_2:
appProtocols = new String { ApplicationProtocols.HTTP_2.id };
break;
default:
appProtocols = new String { ApplicationProtocols.HTTP_2.id, ApplicationProtocols.HTTP_1_1.id };
}
if (Conscrypt.isConscrypt(sslEngine)) {
sslEngine.setSSLParameters(sslParameters);
Conscrypt.setApplicationProtocols(sslEngine, appProtocols);
} else {
H2TlsSupport.setApplicationProtocols(sslParameters, appProtocols);
sslEngine.setSSLParameters(sslParameters);
}
},
(endpoint, sslEngine) -> {
if (Conscrypt.isConscrypt(sslEngine)) {
return new TlsDetails(sslEngine.getSession(), Conscrypt.getApplicationProtocol(sslEngine));
}
return null;
});
return true;
}
return false;
}

}

public static void main(String args) throws Exception {
final SSLContext sslContext = SSLContexts.custom()
.setProvider(Conscrypt.newProvider())
.build();
final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create()
.setTlsStrategy(new ConscriptClientTlsStrategy(sslContext))
.build();
try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setConnectionManager(cm)
.build()) {

client.start();

final HttpHost target = new HttpHost("nghttp2.org", 443, "https");
final String requestUri = "/httpbin";
final HttpClientContext clientContext = HttpClientContext.create();

final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
final Future<SimpleHttpResponse> future = client.execute(
SimpleRequestProducer.create(request),
SimpleResponseConsumer.create(),
clientContext,
new FutureCallback<SimpleHttpResponse>() {

@Override
public void completed(final SimpleHttpResponse response) {
System.out.println(requestUri + "->" + response.getCode() + " " +
clientContext.getProtocolVersion());
System.out.println(response.getBody());
final SSLSession sslSession = clientContext.getSSLSession();
if (sslSession != null) {
System.out.println("SSL protocol " + sslSession.getProtocol());
System.out.println("SSL cipher suite " + sslSession.getCipherSuite());
}
}

@Override
public void failed(final Exception ex) {
System.out.println(requestUri + "->" + ex);
}

@Override
public void cancelled() {
System.out.println(requestUri + " cancelled");
}

});
future.get();

System.out.println("Shutting down");
client.shutdown(CloseMode.GRACEFUL);
}
}





share|improve this answer























  • This works with few modifications, thanks for your efforts @oleg
    – Zyber
    Nov 22 at 13:11










  • @Zyber You might want to share your modifications here or with Apache HttpComponents
    – oleg
    Nov 22 at 17:58










  • the changes are mostly like typos thats why I didn't share, anyway I ll share so that it may help people like me 1. tlsSession.startTls is only accepting 4 parameters(sslcontext, SSLBufferManagement, SSLSessionInitializer, SSLSessionVerifier) it doesnt accept host as a parameter 2.second parameter in above method only accepts as SSLBufferManagement not as SSLBufferMode like in the code snippet 3.SimpleHttpRequests.GET.create(target, requestUri) can be replaced by SimpleHttpRequest.get(target, requestUri) 4.CloseMode.GRACEFUL can be replace by ShutDownType.GRACEFUL
    – Zyber
    Nov 23 at 5:34












  • And your snippet used CloseableHttpClient, I have changed it to MinimalHttpAsyncClient for multiplexing in http2
    – Zyber
    Nov 23 at 5:56










  • You are still using 5.0 BETA1. I would recommend upgrading to 5.0 BETA2
    – oleg
    Nov 23 at 8:13













up vote
2
down vote










up vote
2
down vote









Just replacing the default JSSE provider with Conscrypt is not enough. One also needs a custom TlsStrategy that can take advantage of Conscrypt APIs.



This what works for me with Java 1.8 and Conscrypt 1.4.1



static class ConscriptClientTlsStrategy implements TlsStrategy {

private final SSLContext sslContext;

public ConscriptClientTlsStrategy(final SSLContext sslContext) {
this.sslContext = Args.notNull(sslContext, "SSL context");
}

@Override
public boolean upgrade(
final TransportSecurityLayer tlsSession,
final HttpHost host,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final Object attachment) {
final String scheme = host != null ? host.getSchemeName() : null;
if (URIScheme.HTTPS.same(scheme)) {
tlsSession.startTls(
sslContext,
host,
SSLBufferMode.STATIC,
(endpoint, sslEngine) -> {
final SSLParameters sslParameters = sslEngine.getSSLParameters();
sslParameters.setProtocols(H2TlsSupport.excludeBlacklistedProtocols(sslParameters.getProtocols()));
sslParameters.setCipherSuites(H2TlsSupport.excludeBlacklistedCiphers(sslParameters.getCipherSuites()));
H2TlsSupport.setEnableRetransmissions(sslParameters, false);
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ?
(HttpVersionPolicy) attachment : HttpVersionPolicy.NEGOTIATE;
final String appProtocols;
switch (versionPolicy) {
case FORCE_HTTP_1:
appProtocols = new String { ApplicationProtocols.HTTP_1_1.id };
break;
case FORCE_HTTP_2:
appProtocols = new String { ApplicationProtocols.HTTP_2.id };
break;
default:
appProtocols = new String { ApplicationProtocols.HTTP_2.id, ApplicationProtocols.HTTP_1_1.id };
}
if (Conscrypt.isConscrypt(sslEngine)) {
sslEngine.setSSLParameters(sslParameters);
Conscrypt.setApplicationProtocols(sslEngine, appProtocols);
} else {
H2TlsSupport.setApplicationProtocols(sslParameters, appProtocols);
sslEngine.setSSLParameters(sslParameters);
}
},
(endpoint, sslEngine) -> {
if (Conscrypt.isConscrypt(sslEngine)) {
return new TlsDetails(sslEngine.getSession(), Conscrypt.getApplicationProtocol(sslEngine));
}
return null;
});
return true;
}
return false;
}

}

public static void main(String args) throws Exception {
final SSLContext sslContext = SSLContexts.custom()
.setProvider(Conscrypt.newProvider())
.build();
final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create()
.setTlsStrategy(new ConscriptClientTlsStrategy(sslContext))
.build();
try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setConnectionManager(cm)
.build()) {

client.start();

final HttpHost target = new HttpHost("nghttp2.org", 443, "https");
final String requestUri = "/httpbin";
final HttpClientContext clientContext = HttpClientContext.create();

final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
final Future<SimpleHttpResponse> future = client.execute(
SimpleRequestProducer.create(request),
SimpleResponseConsumer.create(),
clientContext,
new FutureCallback<SimpleHttpResponse>() {

@Override
public void completed(final SimpleHttpResponse response) {
System.out.println(requestUri + "->" + response.getCode() + " " +
clientContext.getProtocolVersion());
System.out.println(response.getBody());
final SSLSession sslSession = clientContext.getSSLSession();
if (sslSession != null) {
System.out.println("SSL protocol " + sslSession.getProtocol());
System.out.println("SSL cipher suite " + sslSession.getCipherSuite());
}
}

@Override
public void failed(final Exception ex) {
System.out.println(requestUri + "->" + ex);
}

@Override
public void cancelled() {
System.out.println(requestUri + " cancelled");
}

});
future.get();

System.out.println("Shutting down");
client.shutdown(CloseMode.GRACEFUL);
}
}





share|improve this answer














Just replacing the default JSSE provider with Conscrypt is not enough. One also needs a custom TlsStrategy that can take advantage of Conscrypt APIs.



This what works for me with Java 1.8 and Conscrypt 1.4.1



static class ConscriptClientTlsStrategy implements TlsStrategy {

private final SSLContext sslContext;

public ConscriptClientTlsStrategy(final SSLContext sslContext) {
this.sslContext = Args.notNull(sslContext, "SSL context");
}

@Override
public boolean upgrade(
final TransportSecurityLayer tlsSession,
final HttpHost host,
final SocketAddress localAddress,
final SocketAddress remoteAddress,
final Object attachment) {
final String scheme = host != null ? host.getSchemeName() : null;
if (URIScheme.HTTPS.same(scheme)) {
tlsSession.startTls(
sslContext,
host,
SSLBufferMode.STATIC,
(endpoint, sslEngine) -> {
final SSLParameters sslParameters = sslEngine.getSSLParameters();
sslParameters.setProtocols(H2TlsSupport.excludeBlacklistedProtocols(sslParameters.getProtocols()));
sslParameters.setCipherSuites(H2TlsSupport.excludeBlacklistedCiphers(sslParameters.getCipherSuites()));
H2TlsSupport.setEnableRetransmissions(sslParameters, false);
final HttpVersionPolicy versionPolicy = attachment instanceof HttpVersionPolicy ?
(HttpVersionPolicy) attachment : HttpVersionPolicy.NEGOTIATE;
final String appProtocols;
switch (versionPolicy) {
case FORCE_HTTP_1:
appProtocols = new String { ApplicationProtocols.HTTP_1_1.id };
break;
case FORCE_HTTP_2:
appProtocols = new String { ApplicationProtocols.HTTP_2.id };
break;
default:
appProtocols = new String { ApplicationProtocols.HTTP_2.id, ApplicationProtocols.HTTP_1_1.id };
}
if (Conscrypt.isConscrypt(sslEngine)) {
sslEngine.setSSLParameters(sslParameters);
Conscrypt.setApplicationProtocols(sslEngine, appProtocols);
} else {
H2TlsSupport.setApplicationProtocols(sslParameters, appProtocols);
sslEngine.setSSLParameters(sslParameters);
}
},
(endpoint, sslEngine) -> {
if (Conscrypt.isConscrypt(sslEngine)) {
return new TlsDetails(sslEngine.getSession(), Conscrypt.getApplicationProtocol(sslEngine));
}
return null;
});
return true;
}
return false;
}

}

public static void main(String args) throws Exception {
final SSLContext sslContext = SSLContexts.custom()
.setProvider(Conscrypt.newProvider())
.build();
final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create()
.setTlsStrategy(new ConscriptClientTlsStrategy(sslContext))
.build();
try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setConnectionManager(cm)
.build()) {

client.start();

final HttpHost target = new HttpHost("nghttp2.org", 443, "https");
final String requestUri = "/httpbin";
final HttpClientContext clientContext = HttpClientContext.create();

final SimpleHttpRequest request = SimpleHttpRequests.GET.create(target, requestUri);
final Future<SimpleHttpResponse> future = client.execute(
SimpleRequestProducer.create(request),
SimpleResponseConsumer.create(),
clientContext,
new FutureCallback<SimpleHttpResponse>() {

@Override
public void completed(final SimpleHttpResponse response) {
System.out.println(requestUri + "->" + response.getCode() + " " +
clientContext.getProtocolVersion());
System.out.println(response.getBody());
final SSLSession sslSession = clientContext.getSSLSession();
if (sslSession != null) {
System.out.println("SSL protocol " + sslSession.getProtocol());
System.out.println("SSL cipher suite " + sslSession.getCipherSuite());
}
}

@Override
public void failed(final Exception ex) {
System.out.println(requestUri + "->" + ex);
}

@Override
public void cancelled() {
System.out.println(requestUri + " cancelled");
}

});
future.get();

System.out.println("Shutting down");
client.shutdown(CloseMode.GRACEFUL);
}
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 at 8:33

























answered Nov 20 at 18:33









oleg

20.3k34053




20.3k34053












  • This works with few modifications, thanks for your efforts @oleg
    – Zyber
    Nov 22 at 13:11










  • @Zyber You might want to share your modifications here or with Apache HttpComponents
    – oleg
    Nov 22 at 17:58










  • the changes are mostly like typos thats why I didn't share, anyway I ll share so that it may help people like me 1. tlsSession.startTls is only accepting 4 parameters(sslcontext, SSLBufferManagement, SSLSessionInitializer, SSLSessionVerifier) it doesnt accept host as a parameter 2.second parameter in above method only accepts as SSLBufferManagement not as SSLBufferMode like in the code snippet 3.SimpleHttpRequests.GET.create(target, requestUri) can be replaced by SimpleHttpRequest.get(target, requestUri) 4.CloseMode.GRACEFUL can be replace by ShutDownType.GRACEFUL
    – Zyber
    Nov 23 at 5:34












  • And your snippet used CloseableHttpClient, I have changed it to MinimalHttpAsyncClient for multiplexing in http2
    – Zyber
    Nov 23 at 5:56










  • You are still using 5.0 BETA1. I would recommend upgrading to 5.0 BETA2
    – oleg
    Nov 23 at 8:13


















  • This works with few modifications, thanks for your efforts @oleg
    – Zyber
    Nov 22 at 13:11










  • @Zyber You might want to share your modifications here or with Apache HttpComponents
    – oleg
    Nov 22 at 17:58










  • the changes are mostly like typos thats why I didn't share, anyway I ll share so that it may help people like me 1. tlsSession.startTls is only accepting 4 parameters(sslcontext, SSLBufferManagement, SSLSessionInitializer, SSLSessionVerifier) it doesnt accept host as a parameter 2.second parameter in above method only accepts as SSLBufferManagement not as SSLBufferMode like in the code snippet 3.SimpleHttpRequests.GET.create(target, requestUri) can be replaced by SimpleHttpRequest.get(target, requestUri) 4.CloseMode.GRACEFUL can be replace by ShutDownType.GRACEFUL
    – Zyber
    Nov 23 at 5:34












  • And your snippet used CloseableHttpClient, I have changed it to MinimalHttpAsyncClient for multiplexing in http2
    – Zyber
    Nov 23 at 5:56










  • You are still using 5.0 BETA1. I would recommend upgrading to 5.0 BETA2
    – oleg
    Nov 23 at 8:13
















This works with few modifications, thanks for your efforts @oleg
– Zyber
Nov 22 at 13:11




This works with few modifications, thanks for your efforts @oleg
– Zyber
Nov 22 at 13:11












@Zyber You might want to share your modifications here or with Apache HttpComponents
– oleg
Nov 22 at 17:58




@Zyber You might want to share your modifications here or with Apache HttpComponents
– oleg
Nov 22 at 17:58












the changes are mostly like typos thats why I didn't share, anyway I ll share so that it may help people like me 1. tlsSession.startTls is only accepting 4 parameters(sslcontext, SSLBufferManagement, SSLSessionInitializer, SSLSessionVerifier) it doesnt accept host as a parameter 2.second parameter in above method only accepts as SSLBufferManagement not as SSLBufferMode like in the code snippet 3.SimpleHttpRequests.GET.create(target, requestUri) can be replaced by SimpleHttpRequest.get(target, requestUri) 4.CloseMode.GRACEFUL can be replace by ShutDownType.GRACEFUL
– Zyber
Nov 23 at 5:34






the changes are mostly like typos thats why I didn't share, anyway I ll share so that it may help people like me 1. tlsSession.startTls is only accepting 4 parameters(sslcontext, SSLBufferManagement, SSLSessionInitializer, SSLSessionVerifier) it doesnt accept host as a parameter 2.second parameter in above method only accepts as SSLBufferManagement not as SSLBufferMode like in the code snippet 3.SimpleHttpRequests.GET.create(target, requestUri) can be replaced by SimpleHttpRequest.get(target, requestUri) 4.CloseMode.GRACEFUL can be replace by ShutDownType.GRACEFUL
– Zyber
Nov 23 at 5:34














And your snippet used CloseableHttpClient, I have changed it to MinimalHttpAsyncClient for multiplexing in http2
– Zyber
Nov 23 at 5:56




And your snippet used CloseableHttpClient, I have changed it to MinimalHttpAsyncClient for multiplexing in http2
– Zyber
Nov 23 at 5:56












You are still using 5.0 BETA1. I would recommend upgrading to 5.0 BETA2
– oleg
Nov 23 at 8:13




You are still using 5.0 BETA1. I would recommend upgrading to 5.0 BETA2
– oleg
Nov 23 at 8:13


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387107%2fconscrypt-with-jdk8-to-enable-alpn-for-http2%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin