use of org.apache.flink.shaded.netty4.io.netty.handler.ssl.util.FingerprintTrustManagerFactory in project flink by apache.
the class SSLUtils method getTrustManagerFactory.
private static TrustManagerFactory getTrustManagerFactory(Configuration config, boolean internal) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
String trustStoreFilePath = getAndCheckOption(config, internal ? SecurityOptions.SSL_INTERNAL_TRUSTSTORE : SecurityOptions.SSL_REST_TRUSTSTORE, SecurityOptions.SSL_TRUSTSTORE);
String trustStorePassword = getAndCheckOption(config, internal ? SecurityOptions.SSL_INTERNAL_TRUSTSTORE_PASSWORD : SecurityOptions.SSL_REST_TRUSTSTORE_PASSWORD, SecurityOptions.SSL_TRUSTSTORE_PASSWORD);
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
try (InputStream trustStoreFile = Files.newInputStream(new File(trustStoreFilePath).toPath())) {
trustStore.load(trustStoreFile, trustStorePassword.toCharArray());
}
String certFingerprint = config.getString(internal ? SecurityOptions.SSL_INTERNAL_CERT_FINGERPRINT : SecurityOptions.SSL_REST_CERT_FINGERPRINT);
TrustManagerFactory tmf;
if (StringUtils.isNullOrWhitespaceOnly(certFingerprint)) {
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
} else {
tmf = new FingerprintTrustManagerFactory(certFingerprint.split(","));
}
tmf.init(trustStore);
return tmf;
}
Aggregations