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


Java InsecureTrustManagerFactory.INSTANCE属性代码示例

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


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

示例1: trustManager

private static TrustManagerFactory trustManager(NetworkSslConfig cfg, ResourceService resources) throws GeneralSecurityException,
    IOException, ResourceLoadingException {
    if (cfg.getTrustStorePath() == null || cfg.getTrustStorePath().isEmpty()) {
        return InsecureTrustManagerFactory.INSTANCE;
    } else {
        TrustManagerFactory factory;

        if (cfg.getTrustStoreAlgorithm() == null || cfg.getTrustStoreAlgorithm().isEmpty()) {
            factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        } else {
            factory = TrustManagerFactory.getInstance(cfg.getTrustStoreAlgorithm());
        }

        KeyStore store = keyStore(cfg.getTrustStorePath(), cfg.getTrustStorePassword(), cfg.getTrustStoreType(), resources);

        factory.init(store);

        return factory;
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:20,代码来源:NettySslUtils.java

示例2: HttpClient

public HttpClient(String uri, boolean useInsecureTrustManagerFactory)
		throws URISyntaxException, UnsupportedOperationException {
	trustManagerFactory = useInsecureTrustManagerFactory ? InsecureTrustManagerFactory.INSTANCE : null;

	bootstrap = new Bootstrap();

	httpRequest = new HttpRequest(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri));

	if (!httpRequest().uriObject().getScheme().equalsIgnoreCase("http")
			&& !httpRequest().uriObject().getScheme().equalsIgnoreCase("https")) {
		String message = "HTTP(S) is supported only.";
		logger.error(message);
		throw new UnsupportedOperationException(message);
	}
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:15,代码来源:HttpClient.java

示例3: MqttClient

public MqttClient(String uri, boolean useInsecureTrustManagerFactory) throws URISyntaxException {
	this.bootstrap = new Bootstrap();
	this.uri = new URI(uri);
	this.trustManagerFactory = useInsecureTrustManagerFactory ? InsecureTrustManagerFactory.INSTANCE : null;
	this.sharedObject = new SharedObject();
	this.options = new ConnectOptions();
	this.currentMessageId = 0;
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:8,代码来源:MqttClient.java

示例4: initializeTrustManagerFactory

public TrustManagerFactory initializeTrustManagerFactory() throws DrillException {
  TrustManagerFactory tmf;
  KeyStore ts = null;
  //Support Windows/MacOs system trust store
  try {
    String trustStoreType = getTrustStoreType();
    if ((isWindows || isMacOs) && useSystemTrustStore()) {
      // This is valid for MS-Windows and MacOs
      logger.debug("Initializing System truststore.");
      ts = KeyStore.getInstance(!trustStoreType.isEmpty() ? trustStoreType : KeyStore.getDefaultType());
      ts.load(null, null);
    } else if (!getTrustStorePath().isEmpty()) {
        // if truststore is not provided then we will use the default. Note that the default depends on
        // the TrustManagerFactory that in turn depends on the Security Provider.
        // Use null as the truststore which will result in the default truststore being picked up
        logger.debug("Initializing truststore {}.", getTrustStorePath());
        ts = KeyStore.getInstance(!trustStoreType.isEmpty() ? trustStoreType : KeyStore.getDefaultType());
        InputStream tsStream = new FileInputStream(getTrustStorePath());
        ts.load(tsStream, getTrustStorePassword().toCharArray());
    } else {
      logger.debug("Initializing default truststore.");
    }
    if (disableCertificateVerification()) {
      tmf = InsecureTrustManagerFactory.INSTANCE;
    } else {
      tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    }
    tmf.init(ts);
  } catch (Exception e) {
    // Catch any SSL initialization Exceptions here and abort.
    throw new DrillException(
        new StringBuilder()
            .append("Exception while initializing the truststore: [")
            .append(e.getMessage())
            .append("]. ")
            .toString(), e);
  }
  return tmf;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:39,代码来源:SSLConfig.java

示例5: ClientBuilderFactory

@Inject
public ClientBuilderFactory(
    MeterRegistry meterRegistry,
    Tracing tracing,
    Optional<SelfSignedCertificate> selfSignedCertificate,
    Optional<TrustManagerFactory> caTrustManager,
    ServerConfig serverConfig) {
  this.tracing = tracing;
  final TrustManagerFactory trustManagerFactory;
  if (serverConfig.isDisableClientCertificateVerification()) {
    logger.warn("Disabling client SSL verification. This should only happen on local!");
    trustManagerFactory = InsecureTrustManagerFactory.INSTANCE;
  } else if (caTrustManager.isPresent()) {
    trustManagerFactory = caTrustManager.get();
  } else {
    trustManagerFactory = null;
  }

  final Consumer<SslContextBuilder> clientCertificateCustomizer;
  if (selfSignedCertificate.isPresent()) {
    SelfSignedCertificate certificate = selfSignedCertificate.get();
    clientCertificateCustomizer =
        sslContext -> sslContext.keyManager(certificate.certificate(), certificate.privateKey());
  } else if (serverConfig.getTlsCertificatePath().isEmpty()
      || serverConfig.getTlsPrivateKeyPath().isEmpty()) {
    throw new IllegalStateException(
        "No TLS configuration provided, Curiostack does not support clients without TLS "
            + "certificates. Use gradle-curio-cluster-plugin to set up a namespace and TLS.");
  } else {
    clientCertificateCustomizer =
        sslContext ->
            sslContext.keyManager(
                new File(serverConfig.getTlsCertificatePath()),
                new File(serverConfig.getTlsPrivateKeyPath()));
  }

  final Consumer<SslContextBuilder> clientTlsCustomizer;
  if (trustManagerFactory != null) {
    clientTlsCustomizer =
        sslContext -> {
          clientCertificateCustomizer.accept(sslContext);
          sslContext.trustManager(trustManagerFactory);
        };
  } else {
    clientTlsCustomizer = clientCertificateCustomizer;
  }
  clientFactory =
      new ClientFactoryBuilder()
          .sslContextCustomizer(clientTlsCustomizer)
          .meterRegistry(meterRegistry)
          .build();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:52,代码来源:ClientBuilderFactory.java


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