當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。