diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs index a716742..29472d6 100644 --- a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs +++ b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs @@ -13,12 +13,12 @@ namespace FastGithub.HttpServer /// /// 更新工具文件名 /// - protected abstract string CertToolName { get; } + protected abstract string CaCertUpdatePath { get; } /// /// 证书根目录 /// - protected abstract string CertStorePath { get; } + protected abstract string CaCertStorePath { get; } public CaCertInstallerOfLinux(ILogger logger) @@ -32,7 +32,7 @@ namespace FastGithub.HttpServer /// public bool IsSupported() { - return OperatingSystem.IsLinux() && File.Exists(this.CertToolName); + return OperatingSystem.IsLinux() && File.Exists(this.CaCertUpdatePath); } /// @@ -41,7 +41,7 @@ namespace FastGithub.HttpServer /// 证书文件路径 public void Install(string caCertFilePath) { - var destCertFilePath = Path.Combine(this.CertStorePath, "fastgithub.crt"); + var destCertFilePath = Path.Combine(this.CaCertStorePath, "fastgithub.crt"); if (File.Exists(destCertFilePath) && File.ReadAllBytes(caCertFilePath).SequenceEqual(File.ReadAllBytes(destCertFilePath))) { return; @@ -55,9 +55,10 @@ namespace FastGithub.HttpServer try { - Directory.CreateDirectory(this.CertStorePath); + Directory.CreateDirectory(this.CaCertStorePath); File.Copy(caCertFilePath, destCertFilePath, overwrite: true); - Process.Start(this.CertToolName).WaitForExit(); + Process.Start(this.CaCertUpdatePath).WaitForExit(); + this.logger.LogInformation($"已自动向系统安装根证书"); } catch (Exception ex) { diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs b/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs index 36af3fb..5a7eb62 100644 --- a/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs +++ b/FastGithub.HttpServer/CaCertInstallerOfLinuxDebian.cs @@ -4,9 +4,9 @@ namespace FastGithub.HttpServer { sealed class CaCertInstallerOfLinuxDebian : CaCertInstallerOfLinux { - protected override string CertToolName => "update-ca-certificates"; + protected override string CaCertUpdatePath => "/bin/update-ca-certificates"; - protected override string CertStorePath => "/usr/local/share/ca-certificates"; + protected override string CaCertStorePath => "/usr/local/share/ca-certificates"; public CaCertInstallerOfLinuxDebian(ILogger logger) : base(logger) diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs b/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs index c98f53f..897c445 100644 --- a/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs +++ b/FastGithub.HttpServer/CaCertInstallerOfLinuxRedHat.cs @@ -4,9 +4,9 @@ namespace FastGithub.HttpServer { sealed class CaCertInstallerOfLinuxRedHat : CaCertInstallerOfLinux { - protected override string CertToolName => "update-ca-trust"; + protected override string CaCertUpdatePath => "/bin/update-ca-trust"; - protected override string CertStorePath => "/etc/pki/ca-trust/source/anchors"; + protected override string CaCertStorePath => "/etc/pki/ca-trust/source/anchors"; public CaCertInstallerOfLinuxRedHat(ILogger logger) : base(logger) diff --git a/FastGithub.HttpServer/CaCertInstallerOfWindows.cs b/FastGithub.HttpServer/CaCertInstallerOfWindows.cs index d6d152f..7b87e2e 100644 --- a/FastGithub.HttpServer/CaCertInstallerOfWindows.cs +++ b/FastGithub.HttpServer/CaCertInstallerOfWindows.cs @@ -6,9 +6,9 @@ namespace FastGithub.HttpServer { sealed class CaCertInstallerOfWindows : ICaCertInstaller { - private readonly Logger logger; + private readonly ILogger logger; - public CaCertInstallerOfWindows(Logger logger) + public CaCertInstallerOfWindows(ILogger logger) { this.logger = logger; }