当前位置: 首页>>代码示例>>Java>>正文


Java SelfSignedCertificate类代码示例

本文整理汇总了Java中io.netty.handler.ssl.util.SelfSignedCertificate的典型用法代码示例。如果您正苦于以下问题:Java SelfSignedCertificate类的具体用法?Java SelfSignedCertificate怎么用?Java SelfSignedCertificate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SelfSignedCertificate类属于io.netty.handler.ssl.util包,在下文中一共展示了SelfSignedCertificate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sshExchangeAbsoluteGet

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
@Test
public void sshExchangeAbsoluteGet() throws CertificateException, SSLException {
	SelfSignedCertificate ssc = new SelfSignedCertificate();
	SslContext sslServer = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
	SslContext sslClient = SslContextBuilder.forClient()
	                                        .trustManager(ssc.cert()).build();

	NettyContext context =
			HttpServer.create(opt -> opt.sslContext(sslServer))
			          .newHandler((req, resp) -> resp.sendString(Flux.just("hello ", req.uri())))
			          .block();

	HttpClientResponse response = HttpClient.create(
			opt -> applyHostAndPortFromContext(opt, context)
					.sslContext(sslClient))
			.get("/foo").block();
	context.dispose();
	context.onClose().block();

	String responseString = response.receive().aggregate().asString(CharsetUtil.UTF_8).block();
	assertThat(responseString).isEqualTo("hello /foo");
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:23,代码来源:HttpClientTest.java

示例2: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new FactorialServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:26,代码来源:FactorialServer.java

示例3: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
        .build();

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new SecureChatServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:21,代码来源:SecureChatServer.java

示例4: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new HttpCorsServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:26,代码来源:HttpCorsServer.java

示例5: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new WorldClockServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:26,代码来源:WorldClockServer.java

示例6: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new TelnetServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:26,代码来源:TelnetServer.java

示例7: testSuccess_connectionMetrics_twoConnections_differentClients

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
@Test
public void testSuccess_connectionMetrics_twoConnections_differentClients() throws Exception {
  setHandshakeSuccess();
  String certHash = getCertificateHash(clientCertificate);
  assertThat(channel.isActive()).isTrue();

  // Setup the second channel.
  EppServiceHandler eppServiceHandler2 =
      new EppServiceHandler(
          RELAY_HOST,
          RELAY_PATH,
          () -> ACCESS_TOKEN,
          SERVER_HOSTNAME,
          HELLO.getBytes(UTF_8),
          metrics);
  EmbeddedChannel channel2 = setUpNewChannel(eppServiceHandler2);
  X509Certificate clientCertificate2 = new SelfSignedCertificate().cert();
  setHandshakeSuccess(channel2, clientCertificate2);
  String certHash2 = getCertificateHash(clientCertificate2);

  assertThat(channel2.isActive()).isTrue();

  verify(metrics).registerActiveConnection(PROTOCOL, certHash, channel);
  verify(metrics).registerActiveConnection(PROTOCOL, certHash2, channel2);
  verifyNoMoreInteractions(metrics);
}
 
开发者ID:google,项目名称:nomulus,代码行数:27,代码来源:EppServiceHandlerTest.java

示例8: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	String ip = "127.0.0.1";
	int port = 8080;
	// Configure SSL.
	SelfSignedCertificate ssc = new SelfSignedCertificate();
	final SslContext sslCtx = SslContext.newServerContext(
			ssc.certificate(), ssc.privateKey(), null, null,
			IdentityCipherSuiteFilter.INSTANCE,
			new ApplicationProtocolConfig(Protocol.ALPN,
					SelectorFailureBehavior.FATAL_ALERT,
					SelectedListenerFailureBehavior.FATAL_ALERT,
					SelectedProtocol.SPDY_3_1.protocolName(),
					SelectedProtocol.HTTP_1_1.protocolName()), 0, 0);

	ChannelInitializer<SocketChannel> channelInit = new ChannelInitializer<SocketChannel>() {
		@Override
		protected void initChannel(SocketChannel ch) throws Exception {
			ChannelPipeline p = ch.pipeline();
			p.addLast(sslCtx.newHandler(ch.alloc()));				
			p.addLast(new SpdyOrHttpHandler());
		}
	};
	NettyServerUtil.newHttpServerBootstrap(ip, port, channelInit);
}
 
开发者ID:duchien85,项目名称:netty-cookbook,代码行数:25,代码来源:HttpServerSPDY.java

示例9: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new FactorialServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:26,代码来源:FactorialServer.java

示例10: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    SslContext sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new SecureChatServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:20,代码来源:SecureChatServer.java

示例11: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL context
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    final SslContext sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new ChannelInitializer<SocketChannel>() {
            @Override
            public void initChannel(SocketChannel ch) throws Exception {
                ch.pipeline().addLast(new PortUnificationServerHandler(sslCtx));
            }
        });

        // Bind and start to accept incoming connections.
        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:27,代码来源:PortUnificationServer.java

示例12: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new HttpCorsServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:26,代码来源:HttpCorsServer.java

示例13: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new WorldClockServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:26,代码来源:WorldClockServer.java

示例14: main

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
    } else {
        sslCtx = null;
    }

    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new TelnetServerInitializer(sslCtx));

        b.bind(PORT).sync().channel().closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:26,代码来源:TelnetServer.java

示例15: startServer

import io.netty.handler.ssl.util.SelfSignedCertificate; //导入依赖的package包/类
/** Starts the server with HTTPS. */
@BeforeClass
public static void startServer() throws Exception {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    ssc = new SelfSignedCertificate("example.com");
    ServerBuilder sb = new ServerBuilder()
            .port(0, SessionProtocol.HTTPS)
            .defaultMaxRequestLength(16 * 1024 * 1024)
            .sslContext(GrpcSslContexts.forServer(ssc.certificate(), ssc.privateKey())
                                       .applicationProtocolConfig(ALPN)
                                       .trustManager(TestUtils.loadCert("ca.pem"))
                                       .build());

    final ArmeriaGrpcServerBuilder builder = new ArmeriaGrpcServerBuilder(sb, new GrpcServiceBuilder(),
                                                                          ctxCapture);
    startStaticServer(builder);
    server = builder.builtServer();
}
 
开发者ID:line,项目名称:armeria,代码行数:21,代码来源:ArmeriaGrpcServerInteropTest.java


注:本文中的io.netty.handler.ssl.util.SelfSignedCertificate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。