This commit is contained in:
mossimo
2021-07-09 23:19:15 +08:00
parent 90eeb05620
commit 296bc1597d
3 changed files with 8 additions and 10 deletions
@@ -27,11 +27,10 @@ namespace System.Application.Services.Implementation
Threading.Tasks.Task.Run(async () =>
{
var file = new FileInfo(Path.Combine(IOPath.AppDataDirectory, $@"sudoShell.js"));
int index = 0;
if (file.Exists)
file.Delete();
var vm = new UI.ViewModels.PasswordWindowViewModel();
vm.SetTitle = AppResources.MacSudoPasswordTips;
vm.Title = AppResources.MacSudoPasswordTips;
await IShowWindowService.Instance.ShowDialog(CustomWindow.Password, vm, string.Empty, ResizeModeCompat.CanResize);
var scriptContent = new Text.StringBuilder();
scriptContent.AppendLine($"#!/bin/bash -e");
@@ -21,14 +21,7 @@ namespace System.Application.UI.ViewModels
{
get => _Password;
set => this.RaiseAndSetIfChanged(ref _Password, value);
}
public string? SetTitle
{
get => Title;
set {
Title = value??"";
}
}
}
string? ITextBoxWindowViewModel.Value { get => Password; set => Password = value; }
@@ -337,7 +337,9 @@ namespace System.Application.Services.Implementation
Toast.Show(SR.CreateCertificateFaild);
return false;
}
var filePath = Path.Combine(IOPath.AppDataDirectory, $@"{CertificateName}.Certificate.cer");
try {
proxyServer.CertificateManager.RootCertificate.SaveCerCertificateFile(filePath);
proxyServer.CertificateManager.TrustRootCertificate();
@@ -347,6 +349,10 @@ namespace System.Application.Services.Implementation
{
//安装证书
IPlatformService.Instance.AdminShell($"security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain {filePath}");
}
}
catch (Exception e) {
Log.Error("CerError", e,"证书安装失败");
}
return IsCertificateInstalled(proxyServer.CertificateManager.RootCertificate);
}