keys: return both private and public key when generating
This commit is contained in:
parent
3496bfba75
commit
d7f5a1cbf8
|
@ -26,14 +26,14 @@ namespace SparkleShare {
|
|||
|
||||
public static class SparkleKeys {
|
||||
|
||||
public static string GenerateKeyPair (string output_path, string key_name)
|
||||
public static string [] GenerateKeyPair (string output_path, string key_name)
|
||||
{
|
||||
key_name += ".key";
|
||||
string key_file_path = Path.Combine (output_path, key_name);
|
||||
|
||||
if (File.Exists (key_file_path)) {
|
||||
SparkleHelpers.DebugInfo ("Auth", "A key pair exists ('" + key_name + "'), leaving it untouched");
|
||||
return key_file_path;
|
||||
return new string [] { key_file_path, key_file_path + ".pub" };
|
||||
|
||||
} else {
|
||||
if (!Directory.Exists (output_path))
|
||||
|
@ -65,7 +65,7 @@ namespace SparkleShare {
|
|||
else
|
||||
SparkleHelpers.DebugInfo ("Auth", "Could not create key pair '" + key_file_path + "'");
|
||||
|
||||
return key_file_path;
|
||||
return return new string [] { key_file_path, key_file_path + ".pub" };
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ namespace SparkleShare {
|
|||
string keys_in_use = process.StandardOutput.ReadToEnd ();
|
||||
process.WaitForExit ();
|
||||
|
||||
SparkleHelpers.DebugInfo ("Auth", "The following keys will be available to SparkleShare: " +
|
||||
SparkleHelpers.DebugInfo ("Auth", "The following keys may be used: " +
|
||||
Environment.NewLine + keys_in_use.Trim ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,8 +286,8 @@ namespace SparkleShare {
|
|||
string keys_path = Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
||||
string key_file_name = "sparkleshare." + Program.Controller.CurrentUser.Email;
|
||||
|
||||
string private_key_file_path = SparkleKeys.GenerateKeyPair (keys_path, key_file_name);
|
||||
SparkleKeys.ImportPrivateKey (private_key_file_path);
|
||||
string [] key_pair = SparkleKeys.GenerateKeyPair (keys_path, key_file_name);
|
||||
SparkleKeys.ImportPrivateKey (key_pair [0]);
|
||||
|
||||
string link_code_file_path = Path.Combine (Program.Controller.FoldersPath,
|
||||
Program.Controller.CurrentUser.Name + "'s link code.txt");
|
||||
|
|
Loading…
Reference in a new issue