Skip to content

Commit

Permalink
[Bug] Fix InstallPluginCommand to use proper key signatures (#1233)
Browse files Browse the repository at this point in the history
The public key has changed since the initial release. This commit fixes the
public key and uses the .sig files that are published to the artifacts site.

Signed-off-by: Nicholas Walter Knize <[email protected]>
  • Loading branch information
nknize authored Sep 10, 2021
1 parent 65abe4a commit aecc7bd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -605,21 +605,21 @@ private Path downloadAndValidate(

/**
* 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 OpenSearch signing key with ID 0934A65836A51424.
* ".sig" to the URL. It is expected that the plugin is signed with the OpenSearch signing key with ID C2EE2AF6542C03B4.
*
* @param zip the path to the downloaded plugin ZIP
* @param urlString the URL source of the downloade plugin ZIP
* @throws IOException if an I/O exception occurs reading from various input streams
* @throws PGPException if the PGP implementation throws an internal exception during verification
*/
void verifySignature(final Path zip, final String urlString) throws IOException, PGPException {
final String ascUrlString = urlString + ".asc";
final URL ascUrl = openUrl(ascUrlString);
final String sigUrlString = urlString + ".sig";
final URL sigUrl = openUrl(sigUrlString);
try (
// fin is a file stream over the downloaded plugin zip whose signature to verify
InputStream fin = pluginZipInputStream(zip);
// sin is a URL stream to the signature corresponding to the downloaded plugin zip
InputStream sin = urlOpenStream(ascUrl);
InputStream sin = urlOpenStream(sigUrl);
// ain is a input stream to the public key in ASCII-Armor format (RFC4880)
InputStream ain = new ArmoredInputStream(getPublicKey())
) {
Expand Down Expand Up @@ -666,7 +666,7 @@ InputStream pluginZipInputStream(final Path zip) throws IOException {
* @return the public key ID
*/
String getPublicKeyId() {
return "0934A65836A51424";
return "C2EE2AF6542C03B4";
}

/**
Expand All @@ -675,7 +675,7 @@ String getPublicKeyId() {
* @return an input stream to the public key
*/
InputStream getPublicKey() {
return InstallPluginCommand.class.getResourceAsStream("/public_key.asc");
return InstallPluginCommand.class.getResourceAsStream("/public_key.sig");
}

/**
Expand Down
52 changes: 0 additions & 52 deletions distribution/tools/plugin-cli/src/main/resources/public_key.asc

This file was deleted.

51 changes: 51 additions & 0 deletions distribution/tools/plugin-cli/src/main/resources/public_key.sig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQINBGCa8OoBEADPB4ULnunicJnz+QeANNMQ5FoaVx7ImHBpLwn4Dmgc189JukZO
WWbJw+fMp4LQRJN78NJQsgmVhyF8jjpqTsznsxK55qymiTaazekh3wXhKXVRhEfB
kA1SYV/Aw+ZSgmbPquZftsRVUwHMD6PW+XODyQlAKeGi7wmG4Wjcn3XTJpr90Axf
kMRV/j0ZpNp+wGUm9nJMtPOIQGu3oMDWtLjxdfFdtC9O/ZrnOueeeO/jl4y3ZQCF
+Z//5ObxAw/yG0/70X31HKyua3p0QAqa74nobw2ttYfgJg0kN5mdf8BmxifmA4zU
uMUcFhc5WbKcA2JT7iaDSSmlz1sjtx7xmWhHzSZNoAi0b/xAIfPa3bknA6ENhGNR
0m/0u2rRyoa8L1nYn4d+FlptzaY81LMz4kY0yWE4L3oBGR82ySAVDP/MRpgyDGYF
HuEsuPT3QlWm0zUgrzWf9xbporhUv/+9eDvagfLrWUauYYpXAOrVEEhRueQGqDVa
1zku3lsdWsH8D2SL1cGqX4Ryb2Hi1+uhM1k20lx8fkoE5oF4v4ap5hd/QtA5VS+C
KYT+iJmI8lXbERxnPTI46hOqnVUqAM0U2UKxVyRk3NAJaX8oz3SIo0Zrl7piYdSK
qCLka9YiQur5oHEXUmGIDwGUSTbbqC92Ni5Crl+aeA8ApOwf19UJt2V0WQARAQAB
tCpPcGVuU2VhcmNoIHByb2plY3QgPG9wZW5zZWFyY2hAYW1hem9uLmNvbT6JAjkE
EwECACMFAmCa8OoCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRA50xmH
kxDT/KBhD/4kvP5eezzBYk+JXfi0JODIiBVT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+veTVDQOGoxf7jOU=
=4bMD
-----END PGP PUBLIC KEY BLOCK-----
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,8 @@ URL openUrl(String urlString) throws IOException {
String checksum = shaCalculator.apply(zipbytes);
Files.write(shaFile, checksum.getBytes(StandardCharsets.UTF_8));
return shaFile.toUri().toURL();
} else if ((url + ".asc").equals(urlString)) {
final Path ascFile = temp.apply("asc").resolve("downloaded.zip" + ".asc");
} else if ((url + ".sig").equals(urlString)) {
final Path ascFile = temp.apply("sig").resolve("downloaded.zip" + ".sig");
final byte[] zipBytes = Files.readAllBytes(pluginZip);
final String asc = signature.apply(zipBytes, secretKey);
Files.write(ascFile, asc.getBytes(StandardCharsets.UTF_8));
Expand Down

0 comments on commit aecc7bd

Please sign in to comment.