diff --git a/LetsEncrypt/Library.cs b/LetsEncrypt/Library.cs index 76e6a81..3ab6a94 100644 --- a/LetsEncrypt/Library.cs +++ b/LetsEncrypt/Library.cs @@ -173,40 +173,5 @@ namespace LetsEncrypt } } } - - - - - public static string RestoreCon(string cmd) - { - var escapedArgs = cmd.Replace("\"", "\\\""); - - var process = new Process() - { - StartInfo = new ProcessStartInfo - { - FileName = "restorecon", - Arguments = $"-v \"{escapedArgs}\"", - RedirectStandardOutput = true, - UseShellExecute = false, - CreateNoWindow = true, - } - }; - process.Start(); - string result = process.StandardOutput.ReadToEnd(); - process.WaitForExit(); - return result; - } - - - } - - - - - - - - } diff --git a/LetsEncrypt/Program.cs b/LetsEncrypt/Program.cs index 61979db..f28f9af 100644 --- a/LetsEncrypt/Program.cs +++ b/LetsEncrypt/Program.cs @@ -68,6 +68,7 @@ namespace LetsEncrypt Console.WriteLine("Certificate and Key exists and valid."); } else { + //check if folder for the site exists if(!Directory.Exists(Path.Combine(settings.www, site.name))) { throw new DirectoryNotFoundException(string.Format("Site {0} wasn't initialized", site.name)); } @@ -88,10 +89,10 @@ namespace LetsEncrypt //ensure to enable static file discovery on server in .well-known/acme-challenge //and listen on 80 port - //create acme directory for web site + //check acme directory of the web site string acme = Path.Combine(settings.www, site.name, settings.acme); if(!Directory.Exists(acme)) { - Directory.CreateDirectory(acme); + throw new DirectoryNotFoundException(string.Format("Directory {0} wasn't created", acme)); } foreach (FileInfo file in new DirectoryInfo(acme).GetFiles()) @@ -104,13 +105,8 @@ namespace LetsEncrypt string token = Path.Combine(acme, splitToken[0]); File.WriteAllText(token, splitToken[1]); - - //for Selinux on centos7 - Console.WriteLine(Library.RestoreCon(token)); } - - break; }