GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Swap to SslContextBuilder in examples · netty/netty@2927cdd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • example/src/main/java/io/netty/example
    • http2
      • client
        • Http2Client.java
      • server
        • Http2Server.java
    • memcache/binary
      • MemcacheClient.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎example/src/main/java/io/netty/example/http2/client/Http2Client.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http2/client/Http2Client.java
+14-13Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
3434
import io.netty.handler.ssl.OpenSsl;
3535
import io.netty.handler.ssl.SslContext;
36+
import io.netty.handler.ssl.SslContextBuilder;
3637
import io.netty.handler.ssl.SslProvider;
3738
import io.netty.handler.ssl.SupportedCipherSuiteFilter;
3839
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
@@ -64,19 +65,19 @@ public static void main(String[] args) throws Exception {
6465
final SslContext sslCtx;
6566
if (SSL) {
6667
SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
67-
sslCtx = SslContext.newClientContext(provider,
68-
null, InsecureTrustManagerFactory.INSTANCE,
69-
Http2SecurityUtil.CIPHERS,
70-
/* NOTE: the following filter may not include all ciphers required by the HTTP/2 specification
71-
* Please refer to the HTTP/2 specification for cipher requirements. */
72-
SupportedCipherSuiteFilter.INSTANCE,
73-
new ApplicationProtocolConfig(
74-
Protocol.ALPN,
75-
SelectorFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
76-
SelectedListenerFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
77-
SelectedProtocol.HTTP_2.protocolName(),
78-
SelectedProtocol.HTTP_1_1.protocolName()),
79-
0, 0);
68+
sslCtx = SslContextBuilder.forClient()
69+
.sslProvider(provider)
70+
/* NOTE: the cipher filter may not include all ciphers required by the HTTP/2 specification.
71+
* Please refer to the HTTP/2 specification for cipher requirements. */
72+
.ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
73+
.trustManager(InsecureTrustManagerFactory.INSTANCE)
74+
.applicationProtocolConfig(new ApplicationProtocolConfig(
75+
Protocol.ALPN,
76+
SelectorFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
77+
SelectedListenerFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
78+
SelectedProtocol.HTTP_2.protocolName(),
79+
SelectedProtocol.HTTP_1_1.protocolName()))
80+
.build();
8081
} else {
8182
sslCtx = null;
8283
}
Collapse file

‎example/src/main/java/io/netty/example/http2/server/Http2Server.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/http2/server/Http2Server.java
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
3333
import io.netty.handler.ssl.OpenSsl;
3434
import io.netty.handler.ssl.SslContext;
35+
import io.netty.handler.ssl.SslContextBuilder;
3536
import io.netty.handler.ssl.SslProvider;
3637
import io.netty.handler.ssl.SupportedCipherSuiteFilter;
3738
import io.netty.handler.ssl.util.SelfSignedCertificate;
@@ -52,19 +53,18 @@ public static void main(String[] args) throws Exception {
5253
if (SSL) {
5354
SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
5455
SelfSignedCertificate ssc = new SelfSignedCertificate();
55-
sslCtx = SslContext.newServerContext(provider,
56-
ssc.certificate(), ssc.privateKey(), null,
57-
Http2SecurityUtil.CIPHERS,
58-
/* NOTE: the following filter may not include all ciphers required by the HTTP/2 specification
59-
* Please refer to the HTTP/2 specification for cipher requirements. */
60-
SupportedCipherSuiteFilter.INSTANCE,
61-
new ApplicationProtocolConfig(
62-
Protocol.ALPN,
63-
SelectorFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
64-
SelectedListenerFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
65-
SelectedProtocol.HTTP_2.protocolName(),
66-
SelectedProtocol.HTTP_1_1.protocolName()),
67-
0, 0);
56+
sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
57+
.sslProvider(provider)
58+
/* NOTE: the cipher filter may not include all ciphers required by the HTTP/2 specification.
59+
* Please refer to the HTTP/2 specification for cipher requirements. */
60+
.ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
61+
.applicationProtocolConfig(new ApplicationProtocolConfig(
62+
Protocol.ALPN,
63+
SelectorFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
64+
SelectedListenerFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
65+
SelectedProtocol.HTTP_2.protocolName(),
66+
SelectedProtocol.HTTP_1_1.protocolName()))
67+
.build();
6868
} else {
6969
sslCtx = null;
7070
}
Collapse file

‎example/src/main/java/io/netty/example/memcache/binary/MemcacheClient.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/memcache/binary/MemcacheClient.java
+3-15Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@
2626
import io.netty.channel.socket.nio.NioSocketChannel;
2727
import io.netty.handler.codec.memcache.binary.BinaryMemcacheClientCodec;
2828
import io.netty.handler.codec.memcache.binary.BinaryMemcacheObjectAggregator;
29-
import io.netty.handler.codec.spdy.SpdyOrHttpChooser.SelectedProtocol;
30-
import io.netty.handler.ssl.ApplicationProtocolConfig;
31-
import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol;
32-
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior;
33-
import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior;
34-
import io.netty.handler.ssl.IdentityCipherSuiteFilter;
3529
import io.netty.handler.ssl.SslContext;
30+
import io.netty.handler.ssl.SslContextBuilder;
3631
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
3732

3833
import java.io.BufferedReader;
@@ -51,15 +46,8 @@ public static void main(String[] args) throws Exception {
5146
// Configure SSL.
5247
final SslContext sslCtx;
5348
if (SSL) {
54-
sslCtx = SslContext.newClientContext(
55-
null, InsecureTrustManagerFactory.INSTANCE, null,
56-
IdentityCipherSuiteFilter.INSTANCE,
57-
new ApplicationProtocolConfig(
58-
Protocol.ALPN,
59-
SelectorFailureBehavior.FATAL_ALERT,
60-
SelectedListenerFailureBehavior.FATAL_ALERT,
61-
SelectedProtocol.HTTP_1_1.protocolName()),
62-
0, 0);
49+
sslCtx = SslContextBuilder.forClient()
50+
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
6351
} else {
6452
sslCtx = null;
6553
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.