Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
SteamTools
提交
7b3e9eac
S
SteamTools
项目概览
jobily
/
SteamTools
10 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SteamTools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7b3e9eac
编写于
8月 16, 2023
作者:
A
Aigio Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🐛
证书信任/安装/删除
上级
39294180
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
108 addition
and
41 deletion
+108
-41
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/Certificate/CertificateManagerImpl.cs
...ices.Implementation/Certificate/CertificateManagerImpl.cs
+26
-24
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/Certificate/LazyCertificateManager.cs
...ices.Implementation/Certificate/LazyCertificateManager.cs
+5
-4
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/ReverseProxyServiceImpl.cs
...eProxy/Services.Implementation/ReverseProxyServiceImpl.cs
+1
-1
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services/Certificate/ICertificateManager.cs
....ReverseProxy/Services/Certificate/ICertificateManager.cs
+3
-3
src/BD.WTTS.Client.Plugins.Accelerator/UI/ViewModels/AcceleratorPageViewModel.cs
...ins.Accelerator/UI/ViewModels/AcceleratorPageViewModel.cs
+22
-6
src/BD.WTTS.Client/Resources/Strings.Designer.cs
src/BD.WTTS.Client/Resources/Strings.Designer.cs
+36
-0
src/BD.WTTS.Client/Resources/Strings.resx
src/BD.WTTS.Client/Resources/Strings.resx
+15
-3
未找到文件。
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/Certificate/CertificateManagerImpl.cs
浏览文件 @
7b3e9eac
...
...
@@ -132,6 +132,7 @@ sealed partial class CertificateManagerImpl : ICertificateManager
validTo
,
Interface
.
PfxFilePath
,
GetPfxPassword
());
RootCertificatePackable
=
X509CertificatePackable
.
CreateX509Certificate2
(
Interface
.
PfxFilePath
,
GetPfxPassword
(),
X509KeyStorageFlags
.
Exportable
);
return
RootCertificate
!=
null
;
}
...
...
@@ -149,8 +150,7 @@ sealed partial class CertificateManagerImpl : ICertificateManager
try
{
x509Store
.
Open
(
OpenFlags
.
ReadWrite
);
var
subjectName
=
RootCertificate
.
Subject
[
3.
.];
foreach
(
var
item
in
x509Store
.
Certificates
.
Find
(
X509FindType
.
FindBySubjectName
,
subjectName
,
false
))
foreach
(
var
item
in
x509Store
.
Certificates
.
Find
(
X509FindType
.
FindBySubjectName
,
CertificateConstants
.
RootCertificateName
,
false
))
{
//if (item.Thumbprint == RootCertificate.Thumbprint)
//{
...
...
@@ -222,13 +222,7 @@ sealed partial class CertificateManagerImpl : ICertificateManager
}
}
async
ValueTask
TrustRootCertificateAsync
()
{
await
PlatformTrustRootCertificateGuideAsync
();
}
/// <inheritdoc cref="ICertificateManager.PlatformTrustRootCertificateGuideAsync"/>
public
async
ValueTask
PlatformTrustRootCertificateGuideAsync
()
public
void
TrustRootCertificate
()
{
try
{
...
...
@@ -249,7 +243,7 @@ sealed partial class CertificateManagerImpl : ICertificateManager
}
else
if
(
OperatingSystem
.
IsMacOS
())
{
await
TrustRootCertificateMacOSAsync
();
TrustRootCertificateMacOS
();
}
else
if
(
OperatingSystem
.
IsLinux
()
&&
!
OperatingSystem
.
IsAndroid
())
{
...
...
@@ -267,14 +261,14 @@ sealed partial class CertificateManagerImpl : ICertificateManager
}
[
SupportedOSPlatform
(
"macOS"
)]
async
ValueTask
TrustRootCertificateMacOSAsync
()
void
TrustRootCertificateMacOS
()
{
var
filePath
=
GetCerFilePathGeneratedWhenNoFileExists
();
if
(
filePath
==
null
)
return
;
var
state
=
platformService
.
TrustRootCertificateAsync
(
filePath
);
//await platformService.RunShellAsync($"security add-trusted-cert -d -r trustRoot -k /Users/{Environment.UserName}/Library/Keychains/login.keychain-db \\\"{filePath}\\\"", true);
if
(
state
.
HasValue
&&
!
state
.
Value
)
await
TrustRootCertificateMacOSAsync
();
TrustRootCertificateMacOS
();
}
[
SupportedOSPlatform
(
"Linux"
)]
...
...
@@ -297,13 +291,16 @@ sealed partial class CertificateManagerImpl : ICertificateManager
}
/// <inheritdoc cref="ICertificateManager.SetupRootCertificate"/>
public
async
ValueTask
<
bool
>
SetupRootCertificateAsync
()
public
bool
SetupRootCertificate
()
{
if
(!
GenerateCertificate
())
return
false
;
if
(!
IsRootCertificateInstalled
)
if
(!
GenerateCertificate
())
return
false
;
var
isRootCertificateInstalled
=
IsRootCertificateInstalled
;
if
(!
isRootCertificateInstalled
)
{
await
TrustRootCertificateAsync
();
return
IsRootCertificateInstalled
;
TrustRootCertificate
();
isRootCertificateInstalled
=
IsRootCertificateInstalled
;
return
isRootCertificateInstalled
;
}
return
true
;
}
...
...
@@ -314,15 +311,17 @@ sealed partial class CertificateManagerImpl : ICertificateManager
//if (reverseProxyService.ProxyRunning)
// return false;
if
(
RootCertificate
==
null
)
{
return
true
;
}
try
{
if
(
OperatingSystem
2
.
IsMacOS
())
if
(
OperatingSystem
.
IsMacOS
())
{
var
cer
=
Serializable
.
SMP2
(
RootCertificatePackable
);
platformService
.
RemoveCertificate
(
cer
);
}
else
if
(
OperatingSystem
2
.
IsLinux
())
else
if
(
OperatingSystem
.
IsLinux
())
{
DeleteRootCertificateLinux
();
}
...
...
@@ -330,13 +329,16 @@ sealed partial class CertificateManagerImpl : ICertificateManager
{
SharedRemoveTrustedRootCertificate
();
}
if
(!
IsRootCertificateInstalled
)
var
isRootCertificateInstalled
=
IsRootCertificateInstalled
;
if
(!
isRootCertificateInstalled
)
{
RootCertificate
=
null
;
RootCertificate
=
default
;
RootCertificatePackable
=
default
;
var
pfxFilePath
=
Interface
.
PfxFilePath
;
var
cerFilePath
=
Interface
.
CerFilePath
;
if
(
File
.
Exists
(
pfxFilePath
))
File
.
Delete
(
pfxFilePath
);
if
(
File
.
Exists
(
cerFilePath
))
File
.
Delete
(
cerFilePath
);
IOPath
.
FileTryDelete
(
pfxFilePath
);
IOPath
.
FileTryDelete
(
cerFilePath
);
return
true
;
}
}
catch
(
CryptographicException
)
...
...
@@ -349,7 +351,7 @@ sealed partial class CertificateManagerImpl : ICertificateManager
e
.
LogAndShowT
(
TAG
,
msg
:
"DeleteRootCertificate Error"
);
return
false
;
}
return
tru
e
;
return
fals
e
;
}
[
SupportedOSPlatform
(
"Linux"
)]
...
...
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/Certificate/LazyCertificateManager.cs
浏览文件 @
7b3e9eac
...
...
@@ -23,14 +23,15 @@ sealed class LazyCertificateManager : ICertificateManager
return
impl
().
GetCerFilePathGeneratedWhenNoFileExists
();
}
public
ValueTask
PlatformTrustRootCertificateGuideAsync
()
public
void
TrustRootCertificate
()
{
return
impl
().
PlatformTrustRootCertificateGuideAsync
();
impl
().
TrustRootCertificate
();
}
public
ValueTask
<
bool
>
SetupRootCertificateAsync
()
public
bool
SetupRootCertificate
()
{
return
impl
().
SetupRootCertificateAsync
();
var
r
=
impl
().
SetupRootCertificate
();
return
r
;
}
public
bool
DeleteRootCertificate
()
...
...
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/ReverseProxyServiceImpl.cs
浏览文件 @
7b3e9eac
...
...
@@ -170,7 +170,7 @@ abstract class ReverseProxyServiceImpl : IReverseProxySettings
if
(!
CertificateManager
.
IsRootCertificateInstalled
)
{
var
isOk
=
await
CertificateManager
.
SetupRootCertificateAsync
();
var
isOk
=
CertificateManager
.
SetupRootCertificate
();
if
(!
isOk
)
{
return
StartProxyResultCode
.
SetupRootCertificateFail
;
...
...
src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services/Certificate/ICertificateManager.cs
浏览文件 @
7b3e9eac
...
...
@@ -45,15 +45,15 @@ public interface ICertificateManager
string
?
GetCerFilePathGeneratedWhenNoFileExists
();
/// <summary>
///
由平台实现的信任根证书引导
,有 Root 权限将尝试执行信任,否则则 UI 引导,跳转网页或弹窗
///
信任根证书
,有 Root 权限将尝试执行信任,否则则 UI 引导,跳转网页或弹窗
/// </summary>
ValueTask
PlatformTrustRootCertificateGuideAsync
();
void
TrustRootCertificate
();
/// <summary>
/// 安装根证书,如果没有证书将生成一个新的
/// </summary>
/// <returns>返回根证书是否受信任</returns>
ValueTask
<
bool
>
SetupRootCertificateAsync
();
bool
SetupRootCertificate
();
/// <summary>
/// 删除根证书,如果没有证书将返回 <see langword="true"/>
...
...
src/BD.WTTS.Client.Plugins.Accelerator/UI/ViewModels/AcceleratorPageViewModel.cs
浏览文件 @
7b3e9eac
...
...
@@ -51,19 +51,35 @@ public sealed partial class AcceleratorPageViewModel
}
}
public
async
void
TrustCer_OnClick
()
public
void
TrustCer_OnClick
()
{
certificateManager
.
GetCerFilePathGeneratedWhenNoFileExists
();
await
certificateManager
.
PlatformTrustRootCertificateGuideAsync
();
certificateManager
.
TrustRootCertificate
();
}
public
async
void
SetupCertificate_OnClick
()
public
void
SetupCertificate_OnClick
()
{
await
certificateManager
.
SetupRootCertificateAsync
();
var
r
=
certificateManager
.
SetupRootCertificate
();
if
(
r
)
{
Toast
.
Show
(
ToastIcon
.
Success
,
Strings
.
CommunityFix_SetupCertificate_Success
);
}
else
{
Toast
.
Show
(
ToastIcon
.
Error
,
Strings
.
CommunityFix_SetupCertificate_Fail
);
}
}
public
bool
DeleteCertificate_OnClick
()
public
void
DeleteCertificate_OnClick
()
{
return
certificateManager
.
DeleteRootCertificate
();
var
r
=
certificateManager
.
DeleteRootCertificate
();
if
(
r
)
{
Toast
.
Show
(
ToastIcon
.
Success
,
Strings
.
CommunityFix_DeleteCertificate_Success
);
}
else
{
Toast
.
Show
(
ToastIcon
.
Error
,
Strings
.
CommunityFix_DeleteCertificate_Fail
);
}
}
}
\ No newline at end of file
src/BD.WTTS.Client/Resources/Strings.Designer.cs
浏览文件 @
7b3e9eac
...
...
@@ -1079,6 +1079,24 @@ namespace BD.WTTS.Client.Resources {
}
}
/// <summary>
/// 查找类似 删除 CA 证书失败 的本地化字符串。
/// </summary>
public
static
string
CommunityFix_DeleteCertificate_Fail
{
get
{
return
ResourceManager
.
GetString
(
"CommunityFix_DeleteCertificate_Fail"
,
resourceCulture
);
}
}
/// <summary>
/// 查找类似 删除 CA 证书成功 的本地化字符串。
/// </summary>
public
static
string
CommunityFix_DeleteCertificate_Success
{
get
{
return
ResourceManager
.
GetString
(
"CommunityFix_DeleteCertificate_Success"
,
resourceCulture
);
}
}
/// <summary>
/// 查找类似 DNS 解析遇到异常,请尝试在代理设置中修改其它 DNS 再次尝试 的本地化字符串。
/// </summary>
...
...
@@ -1322,6 +1340,24 @@ namespace BD.WTTS.Client.Resources {
}
}
/// <summary>
/// 查找类似 安装 CA 证书失败 的本地化字符串。
/// </summary>
public
static
string
CommunityFix_SetupCertificate_Fail
{
get
{
return
ResourceManager
.
GetString
(
"CommunityFix_SetupCertificate_Fail"
,
resourceCulture
);
}
}
/// <summary>
/// 查找类似 安装 CA 证书成功 的本地化字符串。
/// </summary>
public
static
string
CommunityFix_SetupCertificate_Success
{
get
{
return
ResourceManager
.
GetString
(
"CommunityFix_SetupCertificate_Success"
,
resourceCulture
);
}
}
/// <summary>
/// 查找类似 一键加速 的本地化字符串。
/// </summary>
...
...
src/BD.WTTS.Client/Resources/Strings.resx
浏览文件 @
7b3e9eac
...
...
@@ -1771,7 +1771,7 @@
<data
name=
"Enabled"
xml:space=
"preserve"
>
<value>
已启用
</value>
</data>
<data
name=
"Disabled"
xml:space=
"preserve"
>
<data
name=
"Disabled"
xml:space=
"preserve"
>
<value>
已禁用
</value>
</data>
<data
name=
"Error_AnswerIncorrect"
xml:space=
"preserve"
>
...
...
@@ -2667,10 +2667,22 @@
<data
name=
"YouNeedSignInToGetUID_"
xml:space=
"preserve"
>
<value>
需要登录 {0} 账号才能获取 UID
</value>
</data>
<data
name=
"Script_ImportLoading"
xml:space=
"preserve"
>
<data
name=
"Script_ImportLoading"
xml:space=
"preserve"
>
<value>
处理导入脚本中
</value>
</data>
<data
name=
"SteamAccountPage_ShareEmpt"
xml:space=
"preserve"
>
<data
name=
"SteamAccountPage_ShareEmpt"
xml:space=
"preserve"
>
<value>
家庭共享库为空
</value>
</data>
<data
name=
"CommunityFix_DeleteCertificate_Fail"
xml:space=
"preserve"
>
<value>
删除 CA 证书失败
</value>
</data>
<data
name=
"CommunityFix_DeleteCertificate_Success"
xml:space=
"preserve"
>
<value>
删除 CA 证书成功
</value>
</data>
<data
name=
"CommunityFix_SetupCertificate_Fail"
xml:space=
"preserve"
>
<value>
安装 CA 证书失败
</value>
</data>
<data
name=
"CommunityFix_SetupCertificate_Success"
xml:space=
"preserve"
>
<value>
安装 CA 证书成功
</value>
</data>
</root>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录