本文整理匯總了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();
}