当前位置: 首页>>代码示例>>Java>>正文


Java SslContextBuilder.keyManager方法代码示例

本文整理汇总了Java中io.netty.handler.ssl.SslContextBuilder.keyManager方法的典型用法代码示例。如果您正苦于以下问题:Java SslContextBuilder.keyManager方法的具体用法?Java SslContextBuilder.keyManager怎么用?Java SslContextBuilder.keyManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.handler.ssl.SslContextBuilder的用法示例。


在下文中一共展示了SslContextBuilder.keyManager方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureSsl

import io.netty.handler.ssl.SslContextBuilder; //导入方法依赖的package包/类
private static void configureSsl(SslConfiguration sslConfiguration,
		SslContextBuilder sslContextBuilder) {

	try {

		if (sslConfiguration.getTrustStoreConfiguration().isPresent()) {
			sslContextBuilder.trustManager(createTrustManagerFactory(sslConfiguration
					.getTrustStoreConfiguration()));
		}

		if (sslConfiguration.getKeyStoreConfiguration().isPresent()) {
			sslContextBuilder.keyManager(createKeyManagerFactory(sslConfiguration
					.getKeyStoreConfiguration()));
		}
	}
	catch (GeneralSecurityException | IOException e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:20,代码来源:ClientHttpConnectorFactory.java

示例2: 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();
}
 
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:14,代码来源:TwoWaySSLFailureIT.java

示例3: 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();
}
 
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:14,代码来源:TwoWaySSLIT.java

示例4: usingNetty

import io.netty.handler.ssl.SslContextBuilder; //导入方法依赖的package包/类
static ClientHttpRequestFactory usingNetty(ClientOptions options,
		SslConfiguration sslConfiguration) throws GeneralSecurityException,
		IOException {

	final Netty4ClientHttpRequestFactory requestFactory = new Netty4ClientHttpRequestFactory();

	if (hasSslConfiguration(sslConfiguration)) {

		SslContextBuilder sslContextBuilder = SslContextBuilder //
				.forClient();

		if (sslConfiguration.getTrustStoreConfiguration().isPresent()) {
			sslContextBuilder
					.trustManager(createTrustManagerFactory(sslConfiguration
							.getTrustStoreConfiguration()));
		}

		if (sslConfiguration.getKeyStoreConfiguration().isPresent()) {
			sslContextBuilder.keyManager(createKeyManagerFactory(sslConfiguration
					.getKeyStoreConfiguration()));
		}

		requestFactory.setSslContext(sslContextBuilder.sslProvider(
				SslProvider.JDK).build());
	}

	requestFactory.setConnectTimeout(Math.toIntExact(options
			.getConnectionTimeout().toMillis()));
	requestFactory.setReadTimeout(Math.toIntExact(options.getReadTimeout()
			.toMillis()));

	return requestFactory;
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:34,代码来源:ClientHttpRequestFactoryFactory.java

示例5: createNettySslContext

import io.netty.handler.ssl.SslContextBuilder; //导入方法依赖的package包/类
public static SslContext createNettySslContext(boolean allowInsecureConnection, String trustCertsFilePath,
                                               Certificate[] certificates, PrivateKey privateKey) throws GeneralSecurityException, SSLException, FileNotFoundException {
    SslContextBuilder builder = SslContextBuilder.forClient();
    if (allowInsecureConnection) {
        builder.trustManager(InsecureTrustManagerFactory.INSTANCE);
    } else {
        if (trustCertsFilePath != null && trustCertsFilePath.length() != 0) {
            builder.trustManager(new FileInputStream(trustCertsFilePath));
        }
    }
    builder.keyManager(privateKey, (X509Certificate[]) certificates);
    return builder.build();
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:14,代码来源:SecurityUtility.java

示例6: getClientInitializer

import io.netty.handler.ssl.SslContextBuilder; //导入方法依赖的package包/类
private ChannelInitializer<LocalChannel> getClientInitializer(
    X509Certificate trustedCertificate,
    PrivateKey privateKey,
    X509Certificate certificate,
    Lock clientLock,
    ByteBuf buffer,
    Exception clientException) {
  return new ChannelInitializer<LocalChannel>() {
    @Override
    protected void initChannel(LocalChannel ch) throws Exception {
      SslContextBuilder sslContextBuilder =
          SslContextBuilder.forClient().trustManager(trustedCertificate);
      if (privateKey != null && certificate != null) {
        sslContextBuilder.keyManager(privateKey, certificate);
      }
      SslHandler sslHandler =
          sslContextBuilder.build().newHandler(ch.alloc(), SSL_HOST, SSL_PORT);

      // Enable hostname verification.
      SSLEngine sslEngine = sslHandler.engine();
      SSLParameters sslParameters = sslEngine.getSSLParameters();
      sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
      sslEngine.setSSLParameters(sslParameters);

      ch.pipeline().addLast("Client SSL Handler", sslHandler);
      ch.pipeline().addLast(new DumpHandler(clientLock, buffer, clientException));
    }
  };
}
 
开发者ID:google,项目名称:nomulus,代码行数:30,代码来源:SslServerInitializerTest.java

示例7: build

import io.netty.handler.ssl.SslContextBuilder; //导入方法依赖的package包/类
@Override
public SSLOptions build() {
    SslContextBuilder sslContextBuilder = SslContextBuilder.forClient();

    if (provider != null) {
        sslContextBuilder.sslProvider(provider);
    }

    if (ciphers != null) {
        sslContextBuilder.ciphers(ciphers);
    }

    if (clientAuth != null) {
        sslContextBuilder.clientAuth(clientAuth);
    }

    if (sessionCacheSize != null) {
        sslContextBuilder.sessionCacheSize(sessionCacheSize);
    }

    if (sessionTimeout != null) {
        sslContextBuilder.sessionTimeout(sessionTimeout.toSeconds());
    }

    if (trustCertChainFile != null) {
        sslContextBuilder.trustManager(trustCertChainFile);
    }

    if (keyManager != null) {
        sslContextBuilder.keyManager(
                keyManager.getKeyCertChainFile(),
                keyManager.getKeyFile(),
                keyManager.getKeyPassword());
    }

    SslContext sslContext;
    try {
        sslContext = sslContextBuilder.build();
    } catch (SSLException e) {
        throw new RuntimeException("Unable to build Netty SslContext", e);
    }

    return new NettySSLOptions(sslContext);
}
 
开发者ID:composable-systems,项目名称:dropwizard-cassandra,代码行数:45,代码来源:NettySSLOptionsFactory.java


注:本文中的io.netty.handler.ssl.SslContextBuilder.keyManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。