Skip to content

Commit

Permalink
Use BC libraries to parse PEM files, increase key length, allow gener…
Browse files Browse the repository at this point in the history
…al use of known cryptographic binary extensions, remove unused BC dependencies

Signed-off-by: Iwan Igonin <[email protected]>

# Conflicts:
#	CHANGELOG-3.0.md
  • Loading branch information
iigonin committed Feb 19, 2025
1 parent e62bf1a commit 62d1786
Show file tree
Hide file tree
Showing 99 changed files with 1,207 additions and 1,365 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Refactor the `:server` module `org.opensearch.client` to `org.opensearch.transport.client` to eliminate top level split packages for JPMS support ([#17272](https://github.com/opensearch-project/OpenSearch/pull/17272))
- Use Lucene `BM25Similarity` as default since the `LegacyBM25Similarity` is marked as deprecated ([#17306](https://github.com/opensearch-project/OpenSearch/pull/17306))
- Wildcard field index only 3gram of the input data [#17349](https://github.com/opensearch-project/OpenSearch/pull/17349)
- Use BC libraries to parse PEM files, increase key length, allow general use of known cryptographic binary extensions, remove unused BC dependencies ([#3420](https://github.com/opensearch-project/OpenSearch/pull/14912))

### Deprecated

Expand Down
4 changes: 0 additions & 4 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,8 @@ if (project != rootProject) {

forbiddenPatterns {
exclude '**/*.wav'
exclude '**/*.p12'
exclude '**/*.jks'
exclude '**/*.crt'
// the file that actually defines nocommit
exclude '**/ForbiddenPatternsTask.java'
exclude '**/*.bcfks'
}

testingConventions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ public class ForbiddenPatternsTask extends DefaultTask {
.exclude("**/*.ico")
.exclude("**/*.jar")
.exclude("**/*.zip")
.exclude("**/*.p12")
.exclude("**/*.jks")
.exclude("**/*.crt")
.exclude("**/*.der")
.exclude("**/*.pem")
.exclude("**/*.key")
.exclude("**/*.bcfks")
.exclude("**/*.keystore")
.exclude("**/*.png");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,15 +548,15 @@ public synchronized void start() {

logToProcessStdout("Creating opensearch keystore with password set to [" + keystorePassword + "]");
if (keystorePassword.length() > 0) {
runOpenSearchBinScriptWithInput(keystorePassword + "\n" + keystorePassword, "opensearch-keystore", "create", "-p");
runOpenSearchBinScriptWithInput(keystorePassword + "\n" + keystorePassword + "\n", "opensearch-keystore", "create", "-p");
} else {
runOpenSearchBinScript("opensearch-keystore", "-v", "create");
}

if (keystoreSettings.isEmpty() == false || keystoreFiles.isEmpty() == false) {
logToProcessStdout("Adding " + keystoreSettings.size() + " keystore settings and " + keystoreFiles.size() + " keystore files");

keystoreSettings.forEach((key, value) -> runKeystoreCommandWithPassword(keystorePassword, value.toString(), "add", "-x", key));
keystoreSettings.forEach((key, value) -> runKeystoreCommandWithPassword(keystorePassword, value.toString(), "add", key));

for (Map.Entry<String, File> entry : keystoreFiles.entrySet()) {
File file = entry.getValue();
Expand Down Expand Up @@ -738,7 +738,12 @@ private void runOpenSearchBinScriptWithInput(String input, String tool, CharSequ
}

private void runKeystoreCommandWithPassword(String keystorePassword, String input, CharSequence... args) {
final String actualInput = keystorePassword.length() > 0 ? keystorePassword + "\n" + input : input;
final String actualInput;
if (keystorePassword.length() > 0) {
actualInput = keystorePassword + "\n" + input + "\n" + input;
} else {
actualInput = input + "\n" + input;
}
runOpenSearchBinScriptWithInput(actualInput, "opensearch-keystore", args);
}

Expand Down
4 changes: 0 additions & 4 deletions client/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ tasks.withType(CheckForbiddenApis).configureEach {
replaceSignatureFiles('jdk-signatures', 'http-signatures')
}

forbiddenPatterns {
exclude '**/*.der'
}

tasks.named('forbiddenApisTest').configure {
//we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage
bundledSignatures -= 'jdk-non-portable'
Expand Down
11 changes: 5 additions & 6 deletions libs/ssl-config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ apply plugin: "opensearch.publish"

dependencies {
api project(':libs:opensearch-common')
api "org.bouncycastle:bcprov-jdk18on:${versions.bouncycastle}"
api "org.bouncycastle:bcpkix-jdk18on:${versions.bouncycastle}"
runtimeOnly "org.bouncycastle:bcutil-jdk18on:${versions.bouncycastle}"

testImplementation(project(":test:framework")) {
exclude group: 'org.opensearch', module: 'opensearch-ssl-config'
Expand All @@ -44,16 +47,12 @@ dependencies {
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}"
}


tasks.named('forbiddenApisMain').configure {
replaceSignatureFiles 'jdk-signatures'
}

forbiddenPatterns {
exclude '**/*.key'
exclude '**/*.pem'
exclude '**/*.p12'
exclude '**/*.jks'
tasks.named("dependencyLicenses").configure {
mapping from: /bc.*/, to: 'bouncycastle'
}

tasks.test {
Expand Down
1 change: 1 addition & 0 deletions libs/ssl-config/licenses/bcutil-jdk18on-1.78.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
81c1f5e06f206be5dad137d563609dbe66c81d31
14 changes: 14 additions & 0 deletions libs/ssl-config/licenses/bouncycastle-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2000 - 2023 The Legion of the Bouncy Castle Inc. (https://www.bouncycastle.org)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions libs/ssl-config/licenses/bouncycastle-NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

package org.opensearch.common.ssl;

import org.bouncycastle.pkcs.PKCSException;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.X509ExtendedKeyManager;

Expand Down Expand Up @@ -91,7 +93,7 @@ private PrivateKey getPrivateKey() {
throw new SslConfigException("the configured ssl private key file [" + key.toAbsolutePath() + "] does not exist", e);
} catch (IOException e) {
throw new SslConfigException("the configured ssl private key file [" + key.toAbsolutePath() + "] cannot be read", e);
} catch (GeneralSecurityException e) {
} catch (PKCSException e) {
throw new SslConfigException("cannot load ssl private key file [" + key.toAbsolutePath() + "]", e);
}
}
Expand Down
Loading

0 comments on commit 62d1786

Please sign in to comment.