Make SslProvider.JDK the default provider for http2 examples using ALPN.
Motivation: When running the http2 example no SslProvider is specified when calling SslContext.newServerContext. This may lead to the provider being determined depending on the availabilty of OpenSsl. But as far as I can tell the OpenSslServerContext does not support APLN, which is the protocol configured in the example. This produces the following error when running the example: Exception in thread "main" java.lang.UnsupportedOperationException: OpenSSL provider does not support ALPN protocol io.netty.handler.ssl.OpenSslServerContext.toNegotiator(OpenSslServerContext.java:391) io.netty.handler.ssl.OpenSslServerContext.<init>(OpenSslServerContext.java:117) io.netty.handler.ssl.SslContext.newServerContext(SslContext.java:238) io.netty.handler.ssl.SslContext.newServerContext(SslContext.java:184) io.netty.handler.ssl.SslContext.newServerContext(SslContext.java:124) io.netty.example.http2.server.Http2Server.main(Http2Server.java:51) Modifications: Force SslProvider.JDK when creating the SslContext since the example is using APLN. Result: There is no longer an error if OpenSsl is supported on the platform in use.
This commit is contained in:
parent
026cc0dccb
commit
e1a65127e2
@ -32,6 +32,7 @@ import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol;
|
||||
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior;
|
||||
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslProvider;
|
||||
import io.netty.handler.ssl.SupportedCipherSuiteFilter;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
import io.netty.util.CharsetUtil;
|
||||
@ -60,7 +61,7 @@ public final class Http2Client {
|
||||
// Configure SSL.
|
||||
final SslContext sslCtx;
|
||||
if (SSL) {
|
||||
sslCtx = SslContext.newClientContext(
|
||||
sslCtx = SslContext.newClientContext(SslProvider.JDK,
|
||||
null, InsecureTrustManagerFactory.INSTANCE,
|
||||
Http2SecurityUtil.CIPHERS,
|
||||
/* NOTE: the following filter may not include all ciphers required by the HTTP/2 specification
|
||||
|
@ -31,6 +31,7 @@ import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol;
|
||||
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior;
|
||||
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslProvider;
|
||||
import io.netty.handler.ssl.SupportedCipherSuiteFilter;
|
||||
import io.netty.handler.ssl.util.SelfSignedCertificate;
|
||||
|
||||
@ -48,7 +49,7 @@ public final class Http2Server {
|
||||
final SslContext sslCtx;
|
||||
if (SSL) {
|
||||
SelfSignedCertificate ssc = new SelfSignedCertificate();
|
||||
sslCtx = SslContext.newServerContext(
|
||||
sslCtx = SslContext.newServerContext(SslProvider.JDK,
|
||||
ssc.certificate(), ssc.privateKey(), null,
|
||||
Http2SecurityUtil.CIPHERS,
|
||||
/* NOTE: the following filter may not include all ciphers required by the HTTP/2 specification
|
||||
|
@ -33,6 +33,7 @@ import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol;
|
||||
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior;
|
||||
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
|
||||
import io.netty.handler.ssl.SslContext;
|
||||
import io.netty.handler.ssl.SslProvider;
|
||||
import io.netty.handler.ssl.SupportedCipherSuiteFilter;
|
||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||
|
||||
@ -52,7 +53,7 @@ public final class MemcacheClient {
|
||||
// Configure SSL.
|
||||
final SslContext sslCtx;
|
||||
if (SSL) {
|
||||
sslCtx = SslContext.newClientContext(
|
||||
sslCtx = SslContext.newClientContext(SslProvider.JDK,
|
||||
null, InsecureTrustManagerFactory.INSTANCE, Http2SecurityUtil.CIPHERS,
|
||||
/* NOTE: the following filter may not include all ciphers required by the HTTP/2 specification
|
||||
* Please refer to the HTTP/2 specification for cipher requirements. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user