Skip to content

Commit

Permalink
🐛 fix cert install
Browse files Browse the repository at this point in the history
  • Loading branch information
xcodebuild committed Dec 25, 2020
1 parent 7222946 commit 2267a83
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LightProxy",
"version": "1.1.41-beta-4",
"version": "1.1.41-beta-5",
"main": "./dist/main.js",
"__note": "This file is generated by scripts/sync-version.js"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LightProxy",
"version": "1.1.41-beta-4",
"version": "1.1.41-beta-5",
"license": "MIT",
"main": "./dist/main.js",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions src/main/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export async function installCertAndHelper() {
await fs.writeFileAsync(path.join(dir, CERT_KEY_FILE_NAME), certs.key, 'utf-8');
await fs.writeFileAsync(path.join(dir, CERT_FILE_NAME), certs.cert, 'utf-8');

const formatPath = (path: string) => '"' + path + '"';

const INSTALL_DONE_FILE = '/tmp/lightproxy-install-done';
// 信任证书 & 安装 helper
const installPromise = new Promise((resolve, reject) => {
Expand All @@ -139,7 +141,11 @@ export async function installCertAndHelper() {
const cmd = `echo "Please input local login password 请输入本地登录密码" && sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "${path.join(
dir,
CERT_FILE_NAME,
)}" && sudo cp "${PROXY_CONF_HELPER_FILE_PATH}" "${PROXY_CONF_HELPER_PATH}" && sudo chown root:admin "${PROXY_CONF_HELPER_PATH}" && sudo chmod a+rx+s "${PROXY_CONF_HELPER_PATH}" && touch ${INSTALL_DONE_FILE}
)}" && sudo cp ${formatPath(PROXY_CONF_HELPER_FILE_PATH)} ${formatPath(
PROXY_CONF_HELPER_PATH,
)} && sudo chown root:admin ${formatPath(PROXY_CONF_HELPER_PATH)} && sudo chmod a+rx+s ${formatPath(
PROXY_CONF_HELPER_PATH,
)} && touch ${INSTALL_DONE_FILE} && echo "安装完成"
`;
clipboard.writeText(cmd);

Expand All @@ -154,6 +160,7 @@ export async function installCertAndHelper() {
while (!fs.existsSync(INSTALL_DONE_FILE)) {
showGuide();
}
resolve(true);
} else {
dialog.showMessageBoxSync({
type: 'info',
Expand All @@ -177,7 +184,7 @@ export async function installCertAndHelper() {
}

// windows dose not need install helper
resolve();
resolve(true);
}
});

Expand Down

0 comments on commit 2267a83

Please sign in to comment.