Skip to content

Commit

Permalink
Remove adding provider
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed May 24, 2018
1 parent a9350f3 commit 50fdd05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,6 @@ private Path downloadAndValidate(
return zip;
}

static {
Security.addProvider(new BouncyCastleProvider());
}

/**
* Verify the signature of the downloaded plugin ZIP. The signature is obtained from the source of the downloaded plugin by appending
* ".asc" to the URL. It is expected that the plugin is signed with the Elastic signing key with ID D27D666CD88E42B4.
Expand Down Expand Up @@ -561,7 +557,7 @@ void verifySignature(final Path zip, final String urlString) throws IOException,
// compute the signature of the downloaded plugin zip
final PGPPublicKeyRingCollection collection = new PGPPublicKeyRingCollection(pin, new JcaKeyFingerprintCalculator());
final PGPPublicKey key = collection.getPublicKey(signature.getKeyID());
signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BC"), key);
signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider(new BouncyCastleProvider()), key);
final byte[] buffer = new byte[1024];
int read;
while ((read = fin.read(buffer)) != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.BCPGOutputStream;
import org.bouncycastle.bcpg.HashAlgorithmTags;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPEncryptedData;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair;
Expand Down Expand Up @@ -1143,7 +1144,7 @@ public void testFailedSignatureVerification() throws Exception {
}

public PGPSecretKey newSecretKey() throws NoSuchAlgorithmException, NoSuchProviderException, PGPException {
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "BC");
final KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
final KeyPair pair = kpg.generateKeyPair();
final PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build().get(HashAlgorithmTags.SHA1);
Expand All @@ -1156,7 +1157,9 @@ public PGPSecretKey newSecretKey() throws NoSuchAlgorithmException, NoSuchProvid
null,
null,
new JcaPGPContentSignerBuilder(pkp.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1),
new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.CAST5, sha1Calc).setProvider("BC").build("passphrase".toCharArray()));
new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.CAST5, sha1Calc)
.setProvider(new BouncyCastleProvider())
.build("passphrase".toCharArray()));
}

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

0 comments on commit 50fdd05

Please sign in to comment.