本文整理汇总了Java中io.netty.handler.ssl.JdkSslContext类的典型用法代码示例。如果您正苦于以下问题:Java JdkSslContext类的具体用法?Java JdkSslContext怎么用?Java JdkSslContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JdkSslContext类属于io.netty.handler.ssl包,在下文中一共展示了JdkSslContext类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: usingNetty
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
static ClientHttpRequestFactory usingNetty(ClientOptions options)
throws IOException, GeneralSecurityException {
SslContext sslContext = new JdkSslContext(SSLContext.getDefault(), true, ClientAuth.REQUIRE);
final Netty4ClientHttpRequestFactory requestFactory = new Netty4ClientHttpRequestFactory();
requestFactory.setSslContext(sslContext);
if (options.getConnectionTimeout() != null) {
requestFactory.setConnectTimeout(options.getConnectionTimeout());
}
if (options.getReadTimeout() != null) {
requestFactory.setReadTimeout(options.getReadTimeout());
}
return requestFactory;
}
开发者ID:spring-projects,项目名称:spring-credhub,代码行数:18,代码来源:ClientHttpRequestFactoryFactory.java
示例2: initSsl
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
private void initSsl(String addr, NettyRequestFactory factory) throws Exception {
SSLContext sslc = SSLContext.getInstance("TLS");
if(!checkSsl) {
log.debug("disable any SSL check on {} address", addr);
sslc.init(null, new TrustManager[]{new SSLUtil.NullX509TrustManager()}, null);
} else if(StringUtils.hasText(keystore)) {
log.debug("use SSL trusted store {} on {} address", keystore, addr);
final String alg = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory def = TrustManagerFactory.getInstance(alg);
def.init((KeyStore)null);// initialize default list of trust managers
Resource resource = resourceLoader.getResource(keystore);
if(!resource.exists()) {
log.warn("Specified JKS {} is not exists.", keystore);
return;
}
KeyStore ks = KeyStore.getInstance("JKS");
try(InputStream is = resource.getInputStream()) {
ks.load(is, storepass == null? new char[0] : storepass.toCharArray());
}
TrustManagerFactory local = TrustManagerFactory.getInstance(alg);
local.init(ks);
TrustManager tm = SSLUtil.combineX509TrustManagers(local.getTrustManagers(), def.getTrustManagers());
sslc.init(null, new TrustManager[]{tm}, null);
}
factory.setSslContext(new JdkSslContext(sslc, true, ClientAuth.OPTIONAL));
}
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:27,代码来源:DockerServiceFactory.java
示例3: testNewInstanceLoader
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
@Test
public void testNewInstanceLoader() throws Exception {
final SslContextReloader reloader = new SslContextReloader(() -> {
return new JdkSslContext(SSLContext.getDefault(), true, ClientAuth.REQUIRE);
});
assertTrue(reloader.load());
assertEquals(ReloadState.RELOADED, reloader.getReloadState());
assertNull(reloader.getDataVersion());
}
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:11,代码来源:SslContextReloaderTest.java
示例4: testStaticInstanceLoader
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
@Test
public void testStaticInstanceLoader() throws Exception {
final JdkSslContext context = new JdkSslContext(SSLContext.getDefault(), true, ClientAuth.REQUIRE);
final SslContextReloader reloader = new SslContextReloader(() -> context);
// don't invoke load here because the constructor forces load the first time
assertEquals(ReloadState.RELOADED, reloader.getReloadState());
assertNull(reloader.getDataVersion());
assertFalse(reloader.load());
assertEquals(ReloadState.NO_CHANGE, reloader.getReloadState());
assertNull(reloader.getDataVersion());
}
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:14,代码来源:SslContextReloaderTest.java
示例5: getSSLSocketFactory
import io.netty.handler.ssl.JdkSslContext; //导入依赖的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();
}
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:14,代码来源:TwoWaySSLFailureIT.java
示例6: getSSLSocketFactory
import io.netty.handler.ssl.JdkSslContext; //导入依赖的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();
}
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:14,代码来源:TwoWaySSLIT.java
示例7: setupSslCtx
import io.netty.handler.ssl.JdkSslContext; //导入依赖的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();
}
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:12,代码来源:WebSocketClientIT.java
示例8: createContext
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
public static SSLContext createContext() {
try {
JdkSslContext nettyContext = (JdkSslContext) SslContextBuilder
.forServer(getKeyManagerFactory())
.sslProvider(SslProvider.JDK)
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.build();
return nettyContext.context();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:14,代码来源:FakeTlsContext.java
示例9: groupAndChannel
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
final void groupAndChannel(ServerBootstrap bootstrap) {
LoopResources loops =
Objects.requireNonNull(getLoopResources(), "loopResources");
boolean useNative = preferNative() && !(sslContext() instanceof JdkSslContext);
final EventLoopGroup selectorGroup = loops.onServerSelect(useNative);
final EventLoopGroup elg = loops.onServer(useNative);
bootstrap.group(selectorGroup, elg)
.channel(loops.onServerChannel(elg));
}
开发者ID:reactor,项目名称:reactor-netty,代码行数:12,代码来源:ServerOptions.java
示例10: groupAndChannel
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
final void groupAndChannel(Bootstrap bootstrap) {
LoopResources loops = Objects.requireNonNull(getLoopResources(), "loopResources");
boolean useNative =
this.protocolFamily == null && preferNative() && !(sslContext() instanceof JdkSslContext);
EventLoopGroup elg = loops.onClient(useNative);
if (this.poolResources != null && elg instanceof Supplier) {
//don't colocate
bootstrap.group(((Supplier<EventLoopGroup>) elg).get());
}
else {
bootstrap.group(elg);
}
if (useDatagramChannel()) {
if (useNative) {
bootstrap.channel(loops.onDatagramChannel(elg));
}
else {
bootstrap.channelFactory(() -> new NioDatagramChannel(protocolFamily));
}
}
else {
bootstrap.channel(loops.onChannel(elg));
}
}
开发者ID:reactor,项目名称:reactor-netty,代码行数:29,代码来源:ClientOptions.java
示例11: newInstance
import io.netty.handler.ssl.JdkSslContext; //导入依赖的package包/类
/**
* Creates instance of Socket.IO server with the given secure port.
*/
public static SocketIOServer newInstance(int port, SSLContext sslContext) {
SslContext nettySslContext = new JdkSslContext(sslContext, false, ClientAuth.NONE);
return newInstance(port, nettySslContext);
}
开发者ID:scalecube,项目名称:socketio,代码行数:8,代码来源:SocketIOServer.java
注:本文中的io.netty.handler.ssl.JdkSslContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论