Skip to content

Commit

Permalink
🐛 Certutil 工具可移除 sql: 字符 减少兼容问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Mossimos committed Nov 17, 2023
1 parent 9e4c483 commit 07d5c3d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions build/linux/environment_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ else
fi
}
certutil_Init() {
certutil -d sql:$HOME/.pki/nssdb -L
certutil -d $HOME/.pki/nssdb -L
ret=$?
if [ $ret -ne 0 ]; then
echo "即将初始化 certutil sql:\$HOME/.pki/nssdb"
mkdir -p sql:$HOME/.pki
mkdir -p sql:$HOME/.pki/nssdb
chmod 700 sql:$HOME/.pki/nssdb
certutil -d sql:$HOME/.pki/nssdb -N --empty-password
echo "即将初始化 certutil \$HOME/.pki/nssdb"
mkdir -p $HOME/.pki
mkdir -p $HOME/.pki/nssdb
chmod 700 $HOME/.pki/nssdb
certutil -d $HOME/.pki/nssdb -N --empty-password
else
echo "certutil nssdb 正常"
fi
Expand Down
12 changes: 6 additions & 6 deletions build/linux/online_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ Install_certutil() {
fi
}
certutil_Init() {
certutil -d sql:$HOME/.pki/nssdb -L
certutil -d $HOME/.pki/nssdb -L
ret=$?
if [ $ret -ne 0 ]; then
echo "即将初始化 certutil sql:\$HOME/.pki/nssdb"
mkdir -p sql:$HOME/.pki
mkdir -p sql:$HOME/.pki/nssdb
chmod 700 sql:$HOME/.pki/nssdb
certutil -d sql:$HOME/.pki/nssdb -N --empty-password
echo "即将初始化 certutil \$HOME/.pki/nssdb"
mkdir -p $HOME/.pki
mkdir -p $HOME/.pki/nssdb
chmod 700 $HOME/.pki/nssdb
certutil -d $HOME/.pki/nssdb -N --empty-password
else
echo "certutil nssdb 正常"
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public bool IsCertificateInstalledCore(X509CertificatePackable certificate2)
if (cert == null)
return false;
//退出码 404 500 被使用
var shellStr = $"CERT_NAME=\"{CertificateConstants.CertificateName}\"; CERT_RESULT=$(certutil -L -d sql:$HOME/.pki/nssdb | grep \"$CERT_NAME\"); if [ -n \"$CERT_RESULT\" ]; then echo \"证书 '$CERT_NAME' 存在。\"; exit 200; else echo \"证书 '$CERT_NAME' 不存在。\"; exit 10; fi";
var shellStr = $"CERT_NAME=\"{CertificateConstants.CertificateName}\"; CERT_RESULT=$(certutil -L -d $HOME/.pki/nssdb | grep \"$CERT_NAME\"); if [ -n \"$CERT_RESULT\" ]; then echo \"证书 '$CERT_NAME' 存在。\"; exit 200; else echo \"证书 '$CERT_NAME' 不存在。\"; exit 10; fi";
var p = Process.Start(Process2.BinBash, new string[] { "-c", shellStr });
p.WaitForExit();
return p.ExitCode == 200;
Expand All @@ -37,20 +37,20 @@ public bool IsCertificateInstalledCore(X509CertificatePackable certificate2)

public bool? TrustRootCertificateAsync(string cerPath)
{
// 使用 Certutil NSS 工具 添加到 sql:$HOME/.pki/nssdb Chrome 信任此储存区
// 使用 Certutil NSS 工具 添加到 $HOME/.pki/nssdb Chrome 信任此储存区
Process.Start(Process2.BinBash, new string[] {
"-c",
$"{Certutil} -A -d sql:$HOME/.pki/nssdb -n \"{CertificateConstants.CertificateName}\" -t C,, -i \"{cerPath}\""
$"{Certutil} -A -d $HOME/.pki/nssdb -n \"{CertificateConstants.CertificateName}\" -t C,, -i \"{cerPath}\""
}).WaitForExit();
return RunRootCommand(PkexecPath, new string[] { GetAppHostPath(), "-ceri", CertificateConstants.AppDataDirectory }) == 0;
}

public void RemoveCertificate(byte[] certificate2)
{
// 使用 Certutil NSS 工具 从 sql:$HOME/.pki/nssdb 中删除证书
// 使用 Certutil NSS 工具 从 $HOME/.pki/nssdb 中删除证书
Process.Start(Process2.BinBash, new string[] {
"-c",
$"{Certutil} -D -d sql:$HOME/.pki/nssdb -n \"{CertificateConstants.CertificateName}\""
$"{Certutil} -D -d $HOME/.pki/nssdb -n \"{CertificateConstants.CertificateName}\""
}).WaitForExit();
RunRootCommand(PkexecPath, new string[] { GetAppHostPath(), "-cerd", CertificateConstants.AppDataDirectory });
}
Expand Down

0 comments on commit 07d5c3d

Please sign in to comment.