public override int Invoke(IEnumerable <string> arguments) { Options.Parse(arguments); config = FileActions.OpenFileFrom(configFilename); if (config == null) { logger.Error($"Did not find or cold not access the file \"{configFilename}\"."); return(0); } publicKey = FindPublicKey(config); privateKey = FindPrivateKey(); if (privateKey == null || publicKey == null) { logger.Error($"Did not find a public key or a private key in {configFilename} or the key dir. Make sure we have the public key in the config file, and the private key as a PEM in the key dir."); return(0); } using (new Stopwatch("Decrypting config")) { encrypt = new Encrypt { PublicKey = publicKey, PrivateKey = privateKey }; Walker.Action = DecryptIf; Walker.FindStringValueByKeys(config.Keys.ToList(), config); } FileActions.SaveFileTo(configFilename, config); return(1); }
public override int Invoke(IEnumerable <string> arguments) { Options.Parse(arguments); config = FileActions.OpenFileFrom(ConfigFilename); if (config == null) { logger.Error($"Did not find or cold not access the file \"{ConfigFilename}\"."); return(0); } // We assume there is a property in at the root of the json that is called public key and holds our public key for writing values. publicKey = FindPublicKey(config); if (publicKey == null) { logger.Error($"Did not find a public key in {ConfigFilename}. Make sure we can find it in the root with the key publicKey"); return(0); } if (KeysToExclude != null) { logger.Info($"Excluding the following keys from encryption: {String.Join(", ", KeysToExclude)}"); } using (new Stopwatch("Encrypting configs")) { encrypt = new Encrypt { PublicKey = publicKey }; Walker.Action = EncryptIf; Walker.FindStringValueByKeys(config.Keys.ToList(), config); } FileActions.SaveFileTo(ConfigFilename, config); return(1); }