Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorverhoek <30193551+verhoek@users.noreply.github.com>2018-12-23 22:32:21 +0300
committerverhoek <30193551+verhoek@users.noreply.github.com>2018-12-23 22:32:21 +0300
commitae5d6ffcc7f98ea4cd92320ad71c19c405b63828 (patch)
tree0dc59ba13e882c607e7114038e8c46f5681d8ae8 /BuildTools
parent94cf55a231f7e72e528bd2e2e97af808d125071c (diff)
Added option to generate new priv/pub key pair without verifying the manifest.
Diffstat (limited to 'BuildTools')
-rw-r--r--BuildTools/AutoUpdateBuilder/Program.cs32
1 files changed, 22 insertions, 10 deletions
diff --git a/BuildTools/AutoUpdateBuilder/Program.cs b/BuildTools/AutoUpdateBuilder/Program.cs
index d2df70e61..de961dea8 100644
--- a/BuildTools/AutoUpdateBuilder/Program.cs
+++ b/BuildTools/AutoUpdateBuilder/Program.cs
@@ -1,10 +1,24 @@
using System;
using System.Collections.Generic;
+using System.Security.Cryptography;
namespace AutoUpdateBuilder
{
public class Program
{
+ private static RSACryptoServiceProvider privkey;
+
+ private static void CompareToManifestPublicKey()
+ {
+ if (Duplicati.Library.AutoUpdater.AutoUpdateSettings.SignKey == null || privkey.ToXmlString(false) != Duplicati.Library.AutoUpdater.AutoUpdateSettings.SignKey.ToXmlString(false))
+ {
+ Console.WriteLine("The public key in the project is not the same as the public key from the file");
+ Console.WriteLine("Try setting the key to: ");
+ Console.WriteLine(privkey.ToXmlString(false));
+ System.Environment.Exit(5);
+ }
+ }
+
public static int Main(string[] _args)
{
var args = new List<string>(_args);
@@ -17,16 +31,18 @@ namespace AutoUpdateBuilder
string keyfilepassword;
string gpgkeyfile;
string gpgpath;
+ string allowNewKey;
opts.TryGetValue("input", out inputfolder);
opts.TryGetValue("output", out outputfolder);
+ opts.TryGetValue("allow-new-key", out allowNewKey);
opts.TryGetValue("keyfile", out keyfile);
opts.TryGetValue("manifest", out manifestfile);
opts.TryGetValue("keyfile-password", out keyfilepassword);
opts.TryGetValue("gpgkeyfile", out gpgkeyfile);
opts.TryGetValue("gpgpath", out gpgpath);
- var usedoptions = new string[] { "input", "output", "keyfile", "manifest", "keyfile-password", "gpgkeyfile", "gpgpath" };
+ var usedoptions = new string[] { "allow-new-key", "input", "output", "keyfile", "manifest", "keyfile-password", "gpgkeyfile", "gpgpath" };
if (string.IsNullOrWhiteSpace(inputfolder))
{
@@ -61,7 +77,7 @@ namespace AutoUpdateBuilder
if (!System.IO.File.Exists(keyfile))
{
Console.WriteLine("Keyfile not found, creating new");
- var newkey = System.Security.Cryptography.RSACryptoServiceProvider.Create().ToXmlString(true);
+ var newkey = RSA.Create().ToXmlString(true);
using (var enc = new Duplicati.Library.Encryption.AESEncryption(keyfilepassword, new Dictionary<string, string>()))
using (var fs = System.IO.File.OpenWrite(keyfile))
using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(newkey)))
@@ -71,7 +87,7 @@ namespace AutoUpdateBuilder
if (!System.IO.Directory.Exists(outputfolder))
System.IO.Directory.CreateDirectory(outputfolder);
- var privkey = (System.Security.Cryptography.RSACryptoServiceProvider)System.Security.Cryptography.RSACryptoServiceProvider.Create();
+ privkey = (RSACryptoServiceProvider) RSA.Create();
using(var enc = new Duplicati.Library.Encryption.AESEncryption(keyfilepassword, new Dictionary<string, string>()))
using(var ms = new System.IO.MemoryStream())
@@ -84,16 +100,12 @@ namespace AutoUpdateBuilder
privkey.FromXmlString(sr.ReadToEnd());
}
- if (Duplicati.Library.AutoUpdater.AutoUpdateSettings.SignKey == null || privkey.ToXmlString(false) != Duplicati.Library.AutoUpdater.AutoUpdateSettings.SignKey.ToXmlString(false))
+ if (!Boolean.TryParse(allowNewKey, out Boolean newKeyAllowed) || !newKeyAllowed)
{
- Console.WriteLine("The public key in the project is not the same as the public key from the file");
- Console.WriteLine("Try setting the key to: ");
- Console.WriteLine(privkey.ToXmlString(false));
- return 5;
+ CompareToManifestPublicKey();
}
-
- string gpgkeyid = null;
+ string gpgkeyid = null;
string gpgkeypassphrase = null;
if (string.IsNullOrWhiteSpace(gpgkeyfile))