更新工具完成路径
This commit is contained in:
parent
b824ffece1
commit
b6dd7a6c5e
@ -13,12 +13,12 @@ namespace FastGithub.HttpServer
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新工具文件名
|
/// 更新工具文件名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract string CertToolName { get; }
|
protected abstract string CaCertUpdatePath { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 证书根目录
|
/// 证书根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract string CertStorePath { get; }
|
protected abstract string CaCertStorePath { get; }
|
||||||
|
|
||||||
|
|
||||||
public CaCertInstallerOfLinux(ILogger logger)
|
public CaCertInstallerOfLinux(ILogger logger)
|
||||||
@ -32,7 +32,7 @@ namespace FastGithub.HttpServer
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsSupported()
|
public bool IsSupported()
|
||||||
{
|
{
|
||||||
return OperatingSystem.IsLinux() && File.Exists(this.CertToolName);
|
return OperatingSystem.IsLinux() && File.Exists(this.CaCertUpdatePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -41,7 +41,7 @@ namespace FastGithub.HttpServer
|
|||||||
/// <param name="caCertFilePath">证书文件路径</param>
|
/// <param name="caCertFilePath">证书文件路径</param>
|
||||||
public void Install(string caCertFilePath)
|
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)))
|
if (File.Exists(destCertFilePath) && File.ReadAllBytes(caCertFilePath).SequenceEqual(File.ReadAllBytes(destCertFilePath)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -55,9 +55,10 @@ namespace FastGithub.HttpServer
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(this.CertStorePath);
|
Directory.CreateDirectory(this.CaCertStorePath);
|
||||||
File.Copy(caCertFilePath, destCertFilePath, overwrite: true);
|
File.Copy(caCertFilePath, destCertFilePath, overwrite: true);
|
||||||
Process.Start(this.CertToolName).WaitForExit();
|
Process.Start(this.CaCertUpdatePath).WaitForExit();
|
||||||
|
this.logger.LogInformation($"已自动向系统安装根证书");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,9 +4,9 @@ namespace FastGithub.HttpServer
|
|||||||
{
|
{
|
||||||
sealed class CaCertInstallerOfLinuxDebian : CaCertInstallerOfLinux
|
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<CaCertInstallerOfLinuxDebian> logger)
|
public CaCertInstallerOfLinuxDebian(ILogger<CaCertInstallerOfLinuxDebian> logger)
|
||||||
: base(logger)
|
: base(logger)
|
||||||
|
|||||||
@ -4,9 +4,9 @@ namespace FastGithub.HttpServer
|
|||||||
{
|
{
|
||||||
sealed class CaCertInstallerOfLinuxRedHat : CaCertInstallerOfLinux
|
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<CaCertInstallerOfLinuxRedHat> logger)
|
public CaCertInstallerOfLinuxRedHat(ILogger<CaCertInstallerOfLinuxRedHat> logger)
|
||||||
: base(logger)
|
: base(logger)
|
||||||
|
|||||||
@ -6,9 +6,9 @@ namespace FastGithub.HttpServer
|
|||||||
{
|
{
|
||||||
sealed class CaCertInstallerOfWindows : ICaCertInstaller
|
sealed class CaCertInstallerOfWindows : ICaCertInstaller
|
||||||
{
|
{
|
||||||
private readonly Logger<CaCertInstallerOfWindows> logger;
|
private readonly ILogger<CaCertInstallerOfWindows> logger;
|
||||||
|
|
||||||
public CaCertInstallerOfWindows(Logger<CaCertInstallerOfWindows> logger)
|
public CaCertInstallerOfWindows(ILogger<CaCertInstallerOfWindows> logger)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user