Skip to content

Commit 50fdd05

Browse files
committed
Remove adding provider
1 parent a9350f3 commit 50fdd05

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,6 @@ private Path downloadAndValidate(
526526
return zip;
527527
}
528528

529-
static {
530-
Security.addProvider(new BouncyCastleProvider());
531-
}
532-
533529
/**
534530
* Verify the signature of the downloaded plugin ZIP. The signature is obtained from the source of the downloaded plugin by appending
535531
* ".asc" to the URL. It is expected that the plugin is signed with the Elastic signing key with ID D27D666CD88E42B4.
@@ -561,7 +557,7 @@ void verifySignature(final Path zip, final String urlString) throws IOException,
561557
// compute the signature of the downloaded plugin zip
562558
final PGPPublicKeyRingCollection collection = new PGPPublicKeyRingCollection(pin, new JcaKeyFingerprintCalculator());
563559
final PGPPublicKey key = collection.getPublicKey(signature.getKeyID());
564-
signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BC"), key);
560+
signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider(new BouncyCastleProvider()), key);
565561
final byte[] buffer = new byte[1024];
566562
int read;
567563
while ((read = fin.read(buffer)) != -1) {

distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.bouncycastle.bcpg.ArmoredOutputStream;
2727
import org.bouncycastle.bcpg.BCPGOutputStream;
2828
import org.bouncycastle.bcpg.HashAlgorithmTags;
29+
import org.bouncycastle.jce.provider.BouncyCastleProvider;
2930
import org.bouncycastle.openpgp.PGPEncryptedData;
3031
import org.bouncycastle.openpgp.PGPException;
3132
import org.bouncycastle.openpgp.PGPKeyPair;
@@ -1143,7 +1144,7 @@ public void testFailedSignatureVerification() throws Exception {
11431144
}
11441145

11451146
public PGPSecretKey newSecretKey() throws NoSuchAlgorithmException, NoSuchProviderException, PGPException {
1146-
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "BC");
1147+
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
11471148
kpg.initialize(2048);
11481149
final KeyPair pair = kpg.generateKeyPair();
11491150
final PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build().get(HashAlgorithmTags.SHA1);
@@ -1156,7 +1157,9 @@ public PGPSecretKey newSecretKey() throws NoSuchAlgorithmException, NoSuchProvid
11561157
null,
11571158
null,
11581159
new JcaPGPContentSignerBuilder(pkp.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1),
1159-
new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.CAST5, sha1Calc).setProvider("BC").build("passphrase".toCharArray()));
1160+
new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.CAST5, sha1Calc)
1161+
.setProvider(new BouncyCastleProvider())
1162+
.build("passphrase".toCharArray()));
11601163
}
11611164

11621165
private Function<byte[], String> checksum(final MessageDigest digest) {

0 commit comments

Comments
 (0)