forked from I2P_Developers/i2p.i2p
* Plugins: Enforce signing key matches that in plugin.config
This commit is contained in:
@ -10,7 +10,9 @@ import java.util.Properties;
|
||||
|
||||
import net.i2p.CoreVersion;
|
||||
import net.i2p.crypto.TrustedUpdate;
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.SigningPublicKey;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.web.ConfigClientsHelper;
|
||||
import net.i2p.router.web.ConfigUpdateHandler;
|
||||
@ -171,6 +173,15 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
statusDone("<b>" + _("Plugin from {0} contains an invalid key", url) + "</b>");
|
||||
return;
|
||||
}
|
||||
SigningPublicKey spk;
|
||||
try {
|
||||
spk = new SigningPublicKey(pubkey);
|
||||
} catch (DataFormatException dfe) {
|
||||
f.delete();
|
||||
to.delete();
|
||||
statusDone("<b>" + _("Plugin from {0} contains an invalid key", url) + "</b>");
|
||||
return;
|
||||
}
|
||||
|
||||
// add all existing plugin keys, so any conflicts with existing keys
|
||||
// will be discovered and rejected
|
||||
@ -192,8 +203,9 @@ class PluginUpdateRunner extends UpdateRunner {
|
||||
// the key is already in the TrustedUpdate keyring
|
||||
// verify the sig and verify that it is signed by the signer in the plugin.config file
|
||||
// Allow "" as the previously-known signer
|
||||
String signingKeyName = up.verifyAndGetSigner(f);
|
||||
if (!(signer.equals(signingKeyName) || "".equals(signingKeyName))) {
|
||||
boolean ok = up.verify(f, spk);
|
||||
String signingKeyName = up.getKeys().get(spk);
|
||||
if ((!ok) || !(signer.equals(signingKeyName) || "".equals(signingKeyName))) {
|
||||
f.delete();
|
||||
to.delete();
|
||||
if (signingKeyName == null)
|
||||
|
@ -212,9 +212,9 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.8
|
||||
* @since 0.9.8, public since 0.9.14.1
|
||||
*/
|
||||
Map<SigningPublicKey, String> getKeys() {
|
||||
public Map<SigningPublicKey, String> getKeys() {
|
||||
return Collections.unmodifiableMap(_trustedKeys);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user