本文整理汇总了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;
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}