[Rename] refactor libs/ssl-config. (#264)

Refactor the libs/ssl-config module to rename the package names from`org.elasticsearch.common.ssl` to `org.opensearch.common.ssl`.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-03-11 12:17:03 -08:00 committed by Nick Knize
parent ad22e7f4a2
commit 577e2b74aa
35 changed files with 84 additions and 84 deletions

View File

@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
apply plugin: "elasticsearch.publish"
apply plugin: "opensearch.publish"
dependencies {
api project(':libs:elasticsearch-core')
api project(':libs:opensearch-core')
testImplementation(project(":test:framework")) {
exclude group: 'org.elasticsearch', module: 'elasticsearch-ssl-config'
exclude group: 'org.opensearch', module: 'opensearch-ssl-config'
}
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.common.Nullable;

View File

@ -15,7 +15,7 @@
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import java.io.ByteArrayInputStream;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;
@ -35,7 +35,7 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.elasticsearch.common.ssl.SslDiagnostics.getTrustDiagnosticFailure;
import static org.opensearch.common.ssl.SslDiagnostics.getTrustDiagnosticFailure;
public final class DiagnosticTrustManager extends X509ExtendedTrustManager {

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.X509ExtendedKeyManager;
import java.nio.file.Path;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.common.Nullable;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.X509ExtendedKeyManager;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509ExtendedTrustManager;
@ -37,7 +37,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
/**
* A {@link org.elasticsearch.common.ssl.SslTrustConfig} that reads a list of PEM encoded trusted certificates (CAs) from the file
* A {@link org.opensearch.common.ssl.SslTrustConfig} that reads a list of PEM encoded trusted certificates (CAs) from the file
* system.
* Strictly speaking, this class does not require PEM certificates, and will load any file that can be read by
* {@link java.security.cert.CertificateFactory#generateCertificate(InputStream)}.

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.common.CharArrays;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.SSLParameters;
import java.util.Collections;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
/**
* A base exception for problems that occur while trying to configure SSL.

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509ExtendedKeyManager;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.TrustManagerFactory;
import java.security.KeyStore;
@ -164,7 +164,7 @@ public class SslConfigurationKeys {
}
/**
* The list of keys that are used to load a secure setting (such as a password) that would typically be stored in the elasticsearch
* The list of keys that are used to load a secure setting (such as a password) that would typically be stored in the opensearch
* keystore.
*/
public static List<String> getSecureStringKeys() {

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.bootstrap.JavaVersion;
@ -34,29 +34,29 @@ import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.elasticsearch.common.ssl.KeyStoreUtil.inferKeyStoreType;
import static org.elasticsearch.common.ssl.SslConfiguration.ORDERED_PROTOCOL_ALGORITHM_MAP;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.CERTIFICATE;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.CERTIFICATE_AUTHORITIES;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.CIPHERS;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.CLIENT_AUTH;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEY;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEYSTORE_ALGORITHM;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEYSTORE_LEGACY_KEY_PASSWORD;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEYSTORE_LEGACY_PASSWORD;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEYSTORE_PATH;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEYSTORE_SECURE_KEY_PASSWORD;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEYSTORE_SECURE_PASSWORD;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEYSTORE_TYPE;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEY_LEGACY_PASSPHRASE;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.KEY_SECURE_PASSPHRASE;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.PROTOCOLS;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_ALGORITHM;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_LEGACY_PASSWORD;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_PATH;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_SECURE_PASSWORD;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_TYPE;
import static org.elasticsearch.common.ssl.SslConfigurationKeys.VERIFICATION_MODE;
import static org.opensearch.common.ssl.KeyStoreUtil.inferKeyStoreType;
import static org.opensearch.common.ssl.SslConfiguration.ORDERED_PROTOCOL_ALGORITHM_MAP;
import static org.opensearch.common.ssl.SslConfigurationKeys.CERTIFICATE;
import static org.opensearch.common.ssl.SslConfigurationKeys.CERTIFICATE_AUTHORITIES;
import static org.opensearch.common.ssl.SslConfigurationKeys.CIPHERS;
import static org.opensearch.common.ssl.SslConfigurationKeys.CLIENT_AUTH;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEY;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEYSTORE_ALGORITHM;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEYSTORE_LEGACY_KEY_PASSWORD;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEYSTORE_LEGACY_PASSWORD;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEYSTORE_PATH;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEYSTORE_SECURE_KEY_PASSWORD;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEYSTORE_SECURE_PASSWORD;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEYSTORE_TYPE;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEY_LEGACY_PASSPHRASE;
import static org.opensearch.common.ssl.SslConfigurationKeys.KEY_SECURE_PASSPHRASE;
import static org.opensearch.common.ssl.SslConfigurationKeys.PROTOCOLS;
import static org.opensearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_ALGORITHM;
import static org.opensearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_LEGACY_PASSWORD;
import static org.opensearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_PATH;
import static org.opensearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_SECURE_PASSWORD;
import static org.opensearch.common.ssl.SslConfigurationKeys.TRUSTSTORE_TYPE;
import static org.opensearch.common.ssl.SslConfigurationKeys.VERIFICATION_MODE;
/**
* Loads {@link SslConfiguration} from settings.
@ -194,7 +194,7 @@ public abstract class SslConfigurationLoader {
/**
* Resolve all necessary configuration settings, and load a {@link SslConfiguration}.
*
* @param basePath The base path to use for any settings that represent file paths. Typically points to the Elasticsearch
* @param basePath The base path to use for any settings that represent file paths. Typically points to the OpenSearch
* configuration directory.
* @throws SslConfigException For any problems with the configuration, or with loading the required SSL classes.
*/

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.common.Nullable;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.X509ExtendedKeyManager;
import java.nio.file.Path;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.X509ExtendedTrustManager;
import java.nio.file.Path;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import java.util.Collections;
import java.util.LinkedHashMap;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.X509ExtendedKeyManager;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.X509ExtendedTrustManager;
import java.nio.file.Path;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.X509ExtendedTrustManager;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.test.ESTestCase;
import org.junit.Assert;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.test.ESTestCase;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.common.settings.MockSecureSettings;
import org.elasticsearch.common.settings.SecureString;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.EqualsHashCodeTestUtils;
@ -30,7 +30,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.elasticsearch.common.ssl.SslConfigurationLoader.DEFAULT_CIPHERS;
import static org.opensearch.common.ssl.SslConfigurationLoader.DEFAULT_CIPHERS;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.test.ESTestCase;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;

View File

@ -17,7 +17,7 @@
* under the License.
*/
package org.elasticsearch.common.ssl;
package org.opensearch.common.ssl;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;

View File

@ -6,57 +6,57 @@
# 1. Create first CA PEM ("ca1")
elasticsearch-certutil ca --pem --out ca1.zip --days 9999 --ca-dn "CN=Test CA 1"
unzip ca1.zip
opensearch-certutil ca --pem --out ca1.zip --days 9999 --ca-dn "CN=Test CA 1"
unzip ca1.zip
mv ca ca1
# 2. Create first CA PEM ("ca2")
elasticsearch-certutil ca --pem --out ca2.zip --days 9999 --ca-dn "CN=Test CA 2"
unzip ca2.zip
opensearch-certutil ca --pem --out ca2.zip --days 9999 --ca-dn "CN=Test CA 2"
unzip ca2.zip
mv ca ca2
# 3. Create first CA PEM ("ca3")
elasticsearch-certutil ca --pem --out ca3.zip --days 9999 --ca-dn "CN=Test CA 3"
unzip ca3.zip
opensearch-certutil ca --pem --out ca3.zip --days 9999 --ca-dn "CN=Test CA 3"
unzip ca3.zip
mv ca ca3
# 4. Create "cert1" PEM
elasticsearch-certutil cert --pem --out cert1.zip --name cert1 --ip 127.0.0.1 --dns localhost --days 9999 --ca-key ca1/ca.key --ca-cert ca1/ca.crt
opensearch-certutil cert --pem --out cert1.zip --name cert1 --ip 127.0.0.1 --dns localhost --days 9999 --ca-key ca1/ca.key --ca-cert ca1/ca.crt
unzip cert1.zip
# 5. Create "cert2" PEM (same as cert1, but with a password)
elasticsearch-certutil cert --pem --out cert2.zip --name cert2 --ip 127.0.0.1 --dns localhost --days 9999 --ca-key ca1/ca.key --ca-cert ca1/ca.crt --pass "c2-pass"
opensearch-certutil cert --pem --out cert2.zip --name cert2 --ip 127.0.0.1 --dns localhost --days 9999 --ca-key ca1/ca.key --ca-cert ca1/ca.crt --pass "c2-pass"
unzip cert2.zip
# 6. Convert CAs to PKCS#12
for n in 1 2 3
do
keytool -importcert -file ca${n}/ca.crt -alias ca -keystore ca${n}/ca.p12 -storetype PKCS12 -storepass p12-pass -v
keytool -importcert -file ca${n}/ca.crt -alias ca${n} -keystore ca-all/ca.p12 -storetype PKCS12 -storepass p12-pass -v
keytool -importcert -file ca${n}/ca.crt -alias ca -keystore ca${n}/ca.p12 -storetype PKCS12 -storepass p12-pass -v
keytool -importcert -file ca${n}/ca.crt -alias ca${n} -keystore ca-all/ca.p12 -storetype PKCS12 -storepass p12-pass -v
done
# 7. Convert CAs to JKS
for n in 1 2 3
do
keytool -importcert -file ca${n}/ca.crt -alias ca${n} -keystore ca-all/ca.jks -storetype jks -storepass jks-pass -v
keytool -importcert -file ca${n}/ca.crt -alias ca${n} -keystore ca-all/ca.jks -storetype jks -storepass jks-pass -v
done
# 8. Convert Certs to PKCS#12
for Cert in cert1 cert2
for Cert in cert1 cert2
do
openssl pkcs12 -export -out $Cert/$Cert.p12 -inkey $Cert/$Cert.key -in $Cert/$Cert.crt -name $Cert -passout pass:p12-pass
openssl pkcs12 -export -out $Cert/$Cert.p12 -inkey $Cert/$Cert.key -in $Cert/$Cert.crt -name $Cert -passout pass:p12-pass
done
# 9. Import Certs into single PKCS#12 keystore
for Cert in cert1 cert2
for Cert in cert1 cert2
do
keytool -importkeystore -noprompt \
-srckeystore $Cert/$Cert.p12 -srcstoretype PKCS12 -srcstorepass p12-pass \
@ -65,7 +65,7 @@ done
# 10. Import Certs into single JKS keystore with separate key-password
for Cert in cert1 cert2
for Cert in cert1 cert2
do
keytool -importkeystore -noprompt \
-srckeystore $Cert/$Cert.p12 -srcstoretype PKCS12 -srcstorepass p12-pass \
@ -75,7 +75,7 @@ done
# 11. Create a mimic of the first CA ("ca1b") for testing certificates with the same name but different keys
elasticsearch-certutil ca --pem --out ${PWD}/ca1-b.zip --days 9999 --ca-dn "CN=Test CA 1"
opensearch-certutil ca --pem --out ${PWD}/ca1-b.zip --days 9999 --ca-dn "CN=Test CA 1"
unzip ca1-b.zip
mv ca ca1-b

View File

@ -67,13 +67,13 @@ Adding `DSA` and `EC` Keys to the Keystore
[source,shell]
------
keytool -genkeypair -keyalg DSA -alias testnode_dsa -keystore testnode.jks -storepass testnode \
-keypass testnode -validity 10000 -keysize 1024 -dname "CN=Elasticsearch Test Node" \
-keypass testnode -validity 10000 -keysize 1024 -dname "CN=OpenSearch Test Node" \
-ext SAN=dns:localhost,dns:localhost.localdomain,dns:localhost4,dns:localhost4.localdomain4,dns:localhost6,dns:localhost6.localdomain6,ip:127.0.0.1,ip:0:0:0:0:0:0:0:1
------
[source,shell]
------
keytool -genkeypair -keyalg EC -alias testnode_ec -keystore testnode.jks -storepass testnode \
-keypass testnode -validity 10000 -keysize 256 -dname "CN=Elasticsearch Test Node" \
-keypass testnode -validity 10000 -keysize 256 -dname "CN=OpenSearch Test Node" \
-ext SAN=dns:localhost,dns:localhost.localdomain,dns:localhost4,dns:localhost4.localdomain4,dns:localhost6,dns:localhost6.localdomain6,ip:127.0.0.1,ip:0:0:0:0:0:0:0:1
------

View File

@ -27,9 +27,9 @@ import org.elasticsearch.common.settings.SecureSetting;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.ssl.SslConfiguration;
import org.elasticsearch.common.ssl.SslConfigurationKeys;
import org.elasticsearch.common.ssl.SslConfigurationLoader;
import org.opensearch.common.ssl.SslConfiguration;
import org.opensearch.common.ssl.SslConfigurationKeys;
import org.opensearch.common.ssl.SslConfigurationLoader;
import org.elasticsearch.env.Environment;
import org.elasticsearch.watcher.FileChangesListener;
import org.elasticsearch.watcher.FileWatcher;

View File

@ -30,8 +30,8 @@ import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.ssl.PemKeyConfig;
import org.elasticsearch.common.ssl.PemTrustConfig;
import org.opensearch.common.ssl.PemKeyConfig;
import org.opensearch.common.ssl.PemTrustConfig;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.reindex.RemoteInfo;