本文整理匯總了Java中io.netty.handler.ssl.SslContextBuilder.applicationProtocolConfig方法的典型用法代碼示例。如果您正苦於以下問題:Java SslContextBuilder.applicationProtocolConfig方法的具體用法?Java SslContextBuilder.applicationProtocolConfig怎麽用?Java SslContextBuilder.applicationProtocolConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.handler.ssl.SslContextBuilder
的用法示例。
在下文中一共展示了SslContextBuilder.applicationProtocolConfig方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newNettyClientContext
import io.netty.handler.ssl.SslContextBuilder; //導入方法依賴的package包/類
private static SslContext newNettyClientContext(
io.netty.handler.ssl.SslProvider sslProvider, boolean useAlpn) {
try {
TestKeyStore server = TestKeyStore.getServer();
SslContextBuilder ctx =
SslContextBuilder.forClient()
.sslProvider(sslProvider)
.trustManager((X509Certificate[]) server.getPrivateKey("RSA", "RSA")
.getCertificateChain());
if (useAlpn) {
ctx.applicationProtocolConfig(OpenJdkEngineFactoryConfig.NETTY_ALPN_CONFIG);
}
return ctx.build();
} catch (SSLException e) {
throw new RuntimeException(e);
}
}
示例2: newNettyServerContext
import io.netty.handler.ssl.SslContextBuilder; //導入方法依賴的package包/類
private static SslContext newNettyServerContext(
io.netty.handler.ssl.SslProvider sslProvider, boolean useAlpn) {
try {
PrivateKeyEntry server = TestKeyStore.getServer().getPrivateKey("RSA", "RSA");
SslContextBuilder ctx =
SslContextBuilder
.forServer(server.getPrivateKey(),
(X509Certificate[]) server.getCertificateChain())
.sslProvider(sslProvider);
if (useAlpn) {
ctx.applicationProtocolConfig(OpenJdkEngineFactoryConfig.NETTY_ALPN_CONFIG);
}
return ctx.build();
} catch (SSLException e) {
throw new RuntimeException(e);
}
}
示例3: getNettySslContextInner
import io.netty.handler.ssl.SslContextBuilder; //導入方法依賴的package包/類
private SslContext getNettySslContextInner(String host, boolean useH2) throws Exception {
long start = System.currentTimeMillis();
PrivateKeyAndCertChain keyAndCertChain = keyStoreGenerator.generateCertChain(host, Settings.certValidityDays);
logger.debug("Create certificate for {}, cost {} ms", host, System.currentTimeMillis() - start);
SslContextBuilder builder = SslContextBuilder
.forServer(keyAndCertChain.getPrivateKey(), keyAndCertChain.getCertificateChain());
if (useH2) {
// .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
builder.applicationProtocolConfig(new ApplicationProtocolConfig(
ApplicationProtocolConfig.Protocol.ALPN,
SelectorFailureBehavior.NO_ADVERTISE,
SelectedListenerFailureBehavior.ACCEPT,
ApplicationProtocolNames.HTTP_2,
ApplicationProtocolNames.HTTP_1_1));
}
return builder.build();
}
示例4: sslContext
import io.netty.handler.ssl.SslContextBuilder; //導入方法依賴的package包/類
/**
* Sets the {@link SslContext} of this {@link VirtualHost} from the specified {@link SessionProtocol},
* {@code keyCertChainFile}, {@code keyFile} and {@code keyPassword}.
*/
public B sslContext(
SessionProtocol protocol,
File keyCertChainFile, File keyFile, String keyPassword) throws SSLException {
if (requireNonNull(protocol, "protocol") != SessionProtocol.HTTPS) {
throw new IllegalArgumentException("unsupported protocol: " + protocol);
}
final SslContextBuilder builder = SslContextBuilder.forServer(keyCertChainFile, keyFile, keyPassword);
builder.sslProvider(Flags.useOpenSsl() ? SslProvider.OPENSSL : SslProvider.JDK);
builder.ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE);
builder.applicationProtocolConfig(HTTPS_ALPN_CFG);
sslContext(builder.build());
return self();
}
示例5: getSSLSocketFactory
import io.netty.handler.ssl.SslContextBuilder; //導入方法依賴的package包/類
protected SSLSocketFactory getSSLSocketFactory() throws Exception {
SslContextBuilder builder = SslContextBuilder.forClient();
builder.applicationProtocolConfig(ApplicationProtocolConfig.DISABLED);
// Use server cert / key on client side
builder.keyManager(serverCert.key(), (String) null, serverCert.cert());
builder.sslProvider(SslProvider.JDK);
builder.trustManager(clientTrustStoreFile); // Trust the server cert
SslContext ctx = builder.build();
Assert.assertEquals(JdkSslClientContext.class, ctx.getClass());
JdkSslContext jdk = (JdkSslContext) ctx;
SSLContext jdkSslContext = jdk.context();
return jdkSslContext.getSocketFactory();
}
示例6: getSSLSocketFactory
import io.netty.handler.ssl.SslContextBuilder; //導入方法依賴的package包/類
protected SSLSocketFactory getSSLSocketFactory() throws Exception {
SslContextBuilder builder = SslContextBuilder.forClient();
builder.applicationProtocolConfig(ApplicationProtocolConfig.DISABLED);
// Use server cert / key on client side.
builder.keyManager(serverCert.key(), (String) null, serverCert.cert());
builder.sslProvider(SslProvider.JDK);
builder.trustManager(clientTrustStoreFile); // Trust the server cert
SslContext ctx = builder.build();
Assert.assertEquals(JdkSslClientContext.class, ctx.getClass());
JdkSslContext jdk = (JdkSslContext) ctx;
SSLContext jdkSslContext = jdk.context();
return jdkSslContext.getSocketFactory();
}
示例7: setupSslCtx
import io.netty.handler.ssl.SslContextBuilder; //導入方法依賴的package包/類
private void setupSslCtx() throws Exception {
Assert.assertNotNull(clientTrustStoreFile);
SslContextBuilder builder = SslContextBuilder.forClient();
builder.applicationProtocolConfig(ApplicationProtocolConfig.DISABLED);
builder.sslProvider(SslProvider.JDK);
builder.trustManager(clientTrustStoreFile); // Trust the server cert
SslContext ctx = builder.build();
Assert.assertEquals(JdkSslClientContext.class, ctx.getClass());
JdkSslContext jdk = (JdkSslContext) ctx;
sslCtx = jdk.context();
}