本文整理汇总了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();
}
示例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();
}
}
示例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);
}