當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。