From 1fc925b7bd1bff8b006afb281586230f1f6ea3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com> Date: Thu, 11 Nov 2021 23:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E6=AF=94=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.HttpServer/CaCertInstallerOfLinux.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs index 676c519..12ceab3 100644 --- a/FastGithub.HttpServer/CaCertInstallerOfLinux.cs +++ b/FastGithub.HttpServer/CaCertInstallerOfLinux.cs @@ -2,6 +2,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Linq; namespace FastGithub.HttpServer { @@ -32,6 +33,12 @@ namespace FastGithub.HttpServer /// public void Install(string caCertFilePath, ILogger logger) { + var destCertFilePath = Path.Combine(this.RootCertPath, "fastgithub.crt"); + if (File.Exists(destCertFilePath) && File.ReadAllBytes(caCertFilePath).SequenceEqual(File.ReadAllBytes(destCertFilePath))) + { + return; + } + if (Environment.UserName != "root") { logger.LogWarning($"无法自动安装CA证书{caCertFilePath},因为没有root权限"); @@ -41,7 +48,6 @@ namespace FastGithub.HttpServer try { Directory.CreateDirectory(this.RootCertPath); - var destCertFilePath = Path.Combine(this.RootCertPath, "fastgithub.crt"); File.Copy(caCertFilePath, destCertFilePath, overwrite: true); Process.Start(this.CertUpdateFileName).WaitForExit(); }