From b6dd7a6c5e88e7edf33a083104bf3e6df1da0632 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com>
Date: Sat, 13 Nov 2021 11:43:10 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B7=A5=E5=85=B7=E5=AE=8C?=
=?UTF-8?q?=E6=88=90=E8=B7=AF=E5=BE=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub.HttpServer/CaCertInstallerOfLinux.cs | 13 +++++++------
.../CaCertInstallerOfLinuxDebian.cs | 4 ++--
.../CaCertInstallerOfLinuxRedHat.cs | 4 ++--
FastGithub.HttpServer/CaCertInstallerOfWindows.cs | 4 ++--
4 files changed, 13 insertions(+), 12 deletions(-)
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;
}