當前位置: 首頁>>代碼示例>>Java>>正文


Java SslContext.newServerContext方法代碼示例

本文整理匯總了Java中io.netty.handler.ssl.SslContext.newServerContext方法的典型用法代碼示例。如果您正苦於以下問題:Java SslContext.newServerContext方法的具體用法?Java SslContext.newServerContext怎麽用?Java SslContext.newServerContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.handler.ssl.SslContext的用法示例。


在下文中一共展示了SslContext.newServerContext方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: start

import io.netty.handler.ssl.SslContext; //導入方法依賴的package包/類
public void start() throws Exception {
    File cert = Paths.get(getClass().getResource("/ssl/server.pem").toURI()).toFile();
    File keyStore = Paths.get(getClass().getResource("/ssl/server.key").toURI()).toFile();

    SslContext sslCtx = SslContext.newServerContext(cert, keyStore);

    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();

    server = new ServerBootstrap();
    server.group(bossGroup, workerGroup)
          .channel(NioServerSocketChannel.class)
          .option(ChannelOption.SO_BACKLOG, 100)
          .handler(new LoggingHandler(LogLevel.INFO))
          .childHandler(new BasicSSLServerInitializer(sslCtx));

    server.bind(port).sync().channel().closeFuture();
}
 
開發者ID:xushjie1987,項目名稱:es-hadoop-v2.2.0,代碼行數:19,代碼來源:BasicSSLServer.java

示例2: start

import io.netty.handler.ssl.SslContext; //導入方法依賴的package包/類
public void start() throws CertificateException, SSLException, InterruptedException {
    // Configure SSL.
    final SslContext sslCtx;
    if (ssl) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
    } else {
        sslCtx = null;
    }

    // configure metrics
    ScheduledExecutorService metricCollector = Executors.newScheduledThreadPool(1);
    MixServerMetrics metrics = new MixServerMetrics();
    ThroughputCounter throughputCounter = new ThroughputCounter(metricCollector, 5000L, metrics);
    if (jmx) {// register mbean
        MetricsRegistry.registerMBeans(metrics, port);
    }

    // configure initializer
    SessionStore sessionStore = new SessionStore();
    MixServerHandler msgHandler = new MixServerHandler(sessionStore, syncThreshold, scale);
    MixServerInitializer initializer = new MixServerInitializer(msgHandler, throughputCounter,
        sslCtx);

    Runnable cleanSessionTask = new IdleSessionSweeper(sessionStore, sessionTTLinSec * 1000L);
    ScheduledExecutorService idleSessionChecker = Executors.newScheduledThreadPool(1);
    try {
        // start idle session sweeper
        idleSessionChecker.scheduleAtFixedRate(cleanSessionTask, sessionTTLinSec + 10L,
            sweepIntervalInSec, TimeUnit.SECONDS);
        // accept connections
        acceptConnections(initializer, port, numWorkers);
    } finally {
        // release threads
        idleSessionChecker.shutdownNow();
        if (jmx) {
            MetricsRegistry.unregisterMBeans(port);
        }
        metricCollector.shutdownNow();
    }
}
 
開發者ID:apache,項目名稱:incubator-hivemall,代碼行數:42,代碼來源:MixServer.java

示例3: initServerContext

import io.netty.handler.ssl.SslContext; //導入方法依賴的package包/類
protected Server initServerContext(File certChainFile, File keyFile)
        throws SSLException, InterruptedException {
    SslContext sslCtx = SslContext.newServerContext(certChainFile, keyFile);
    return super.start(sslCtx);
}
 
開發者ID:wxyzZ,項目名稱:little_mitm,代碼行數:6,代碼來源:SecureServer.java


注:本文中的io.netty.handler.ssl.SslContext.newServerContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。