|
@@ -148,9 +148,11 @@ public abstract class X509Util implements Closeable, AutoCloseable {
|
|
private String cipherSuitesProperty = getConfigPrefix() + "ciphersuites";
|
|
private String cipherSuitesProperty = getConfigPrefix() + "ciphersuites";
|
|
private String sslKeystoreLocationProperty = getConfigPrefix() + "keyStore.location";
|
|
private String sslKeystoreLocationProperty = getConfigPrefix() + "keyStore.location";
|
|
private String sslKeystorePasswdProperty = getConfigPrefix() + "keyStore.password";
|
|
private String sslKeystorePasswdProperty = getConfigPrefix() + "keyStore.password";
|
|
|
|
+ private String sslKeystorePasswdPathProperty = getConfigPrefix() + "keyStore.passwordPath";
|
|
private String sslKeystoreTypeProperty = getConfigPrefix() + "keyStore.type";
|
|
private String sslKeystoreTypeProperty = getConfigPrefix() + "keyStore.type";
|
|
private String sslTruststoreLocationProperty = getConfigPrefix() + "trustStore.location";
|
|
private String sslTruststoreLocationProperty = getConfigPrefix() + "trustStore.location";
|
|
private String sslTruststorePasswdProperty = getConfigPrefix() + "trustStore.password";
|
|
private String sslTruststorePasswdProperty = getConfigPrefix() + "trustStore.password";
|
|
|
|
+ private String sslTruststorePasswdPathProperty = getConfigPrefix() + "trustStore.passwordPath";
|
|
private String sslTruststoreTypeProperty = getConfigPrefix() + "trustStore.type";
|
|
private String sslTruststoreTypeProperty = getConfigPrefix() + "trustStore.type";
|
|
private String sslContextSupplierClassProperty = getConfigPrefix() + "context.supplier.class";
|
|
private String sslContextSupplierClassProperty = getConfigPrefix() + "context.supplier.class";
|
|
private String sslHostnameVerificationEnabledProperty = getConfigPrefix() + "hostnameVerification";
|
|
private String sslHostnameVerificationEnabledProperty = getConfigPrefix() + "hostnameVerification";
|
|
@@ -202,6 +204,10 @@ public abstract class X509Util implements Closeable, AutoCloseable {
|
|
return sslKeystorePasswdProperty;
|
|
return sslKeystorePasswdProperty;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String getSslKeystorePasswdPathProperty() {
|
|
|
|
+ return sslKeystorePasswdPathProperty;
|
|
|
|
+ }
|
|
|
|
+
|
|
public String getSslKeystoreTypeProperty() {
|
|
public String getSslKeystoreTypeProperty() {
|
|
return sslKeystoreTypeProperty;
|
|
return sslKeystoreTypeProperty;
|
|
}
|
|
}
|
|
@@ -214,6 +220,10 @@ public abstract class X509Util implements Closeable, AutoCloseable {
|
|
return sslTruststorePasswdProperty;
|
|
return sslTruststorePasswdProperty;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String getSslTruststorePasswdPathProperty() {
|
|
|
|
+ return sslTruststorePasswdPathProperty;
|
|
|
|
+ }
|
|
|
|
+
|
|
public String getSslTruststoreTypeProperty() {
|
|
public String getSslTruststoreTypeProperty() {
|
|
return sslTruststoreTypeProperty;
|
|
return sslTruststoreTypeProperty;
|
|
}
|
|
}
|
|
@@ -334,7 +344,7 @@ public abstract class X509Util implements Closeable, AutoCloseable {
|
|
TrustManager[] trustManagers = null;
|
|
TrustManager[] trustManagers = null;
|
|
|
|
|
|
String keyStoreLocationProp = config.getProperty(sslKeystoreLocationProperty, "");
|
|
String keyStoreLocationProp = config.getProperty(sslKeystoreLocationProperty, "");
|
|
- String keyStorePasswordProp = config.getProperty(sslKeystorePasswdProperty, "");
|
|
|
|
|
|
+ String keyStorePasswordProp = getPasswordFromConfigPropertyOrFile(config, sslKeystorePasswdProperty, sslKeystorePasswdPathProperty);
|
|
String keyStoreTypeProp = config.getProperty(sslKeystoreTypeProperty);
|
|
String keyStoreTypeProp = config.getProperty(sslKeystoreTypeProperty);
|
|
|
|
|
|
// There are legal states in some use cases for null KeyManager or TrustManager.
|
|
// There are legal states in some use cases for null KeyManager or TrustManager.
|
|
@@ -354,7 +364,7 @@ public abstract class X509Util implements Closeable, AutoCloseable {
|
|
}
|
|
}
|
|
|
|
|
|
String trustStoreLocationProp = config.getProperty(sslTruststoreLocationProperty, "");
|
|
String trustStoreLocationProp = config.getProperty(sslTruststoreLocationProperty, "");
|
|
- String trustStorePasswordProp = config.getProperty(sslTruststorePasswdProperty, "");
|
|
|
|
|
|
+ String trustStorePasswordProp = getPasswordFromConfigPropertyOrFile(config, sslTruststorePasswdProperty, sslTruststorePasswdPathProperty);
|
|
String trustStoreTypeProp = config.getProperty(sslTruststoreTypeProperty);
|
|
String trustStoreTypeProp = config.getProperty(sslTruststoreTypeProperty);
|
|
|
|
|
|
boolean sslCrlEnabled = config.getBoolean(this.sslCrlEnabledProperty);
|
|
boolean sslCrlEnabled = config.getBoolean(this.sslCrlEnabledProperty);
|
|
@@ -413,6 +423,26 @@ public abstract class X509Util implements Closeable, AutoCloseable {
|
|
.loadTrustStore();
|
|
.loadTrustStore();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns the password specified by the given property or from the file specified by the given path property.
|
|
|
|
+ * If both are specified, the value stored in the file will be returned.
|
|
|
|
+ *
|
|
|
|
+ * @param config Zookeeper configuration
|
|
|
|
+ * @param propertyName property name
|
|
|
|
+ * @param pathPropertyName path property name
|
|
|
|
+ * @return the password value
|
|
|
|
+ */
|
|
|
|
+ public String getPasswordFromConfigPropertyOrFile(final ZKConfig config,
|
|
|
|
+ final String propertyName,
|
|
|
|
+ final String pathPropertyName) {
|
|
|
|
+ String value = config.getProperty(propertyName, "");
|
|
|
|
+ final String pathProperty = config.getProperty(pathPropertyName, "");
|
|
|
|
+ if (!pathProperty.isEmpty()) {
|
|
|
|
+ value = String.valueOf(SecretUtils.readSecret(pathProperty));
|
|
|
|
+ }
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Creates a key manager by loading the key store from the given file of
|
|
* Creates a key manager by loading the key store from the given file of
|
|
* the given type, optionally decrypting it using the given password.
|
|
* the given type, optionally decrypting it using the given password.
|