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 — Fix DiscardClient hang under -Dssl by using a client SSL context (#16… · netty/netty@b55fabc

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • example/src/main/java/io/netty/example/discard
    • DiscardClient.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎example/src/main/java/io/netty/example/discard/DiscardClient.java‎

Copy file name to clipboardExpand all lines: example/src/main/java/io/netty/example/discard/DiscardClient.java
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,29 @@
2323
import io.netty.channel.nio.NioEventLoopGroup;
2424
import io.netty.channel.socket.SocketChannel;
2525
import io.netty.channel.socket.nio.NioSocketChannel;
26-
import io.netty.example.util.ServerUtil;
2726
import io.netty.handler.ssl.SslContext;
27+
import io.netty.handler.ssl.SslContextBuilder;
28+
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
2829

2930
/**
3031
* Keeps sending random data to the specified address.
3132
*/
3233
public final class DiscardClient {
3334

35+
static final boolean SSL = System.getProperty("ssl") != null;
3436
static final String HOST = System.getProperty("host", "127.0.0.1");
3537
static final int PORT = Integer.parseInt(System.getProperty("port", "8009"));
3638
static final int SIZE = Integer.parseInt(System.getProperty("size", "256"));
3739

3840
public static void main(String[] args) throws Exception {
3941
// Configure SSL.
40-
final SslContext sslCtx = ServerUtil.buildSslContext();
42+
final SslContext sslCtx;
43+
if (SSL) {
44+
sslCtx = SslContextBuilder.forClient()
45+
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
46+
} else {
47+
sslCtx = null;
48+
}
4149

4250
EventLoopGroup group = new NioEventLoopGroup();
4351
try {

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.