25 lines
778 B
Bash
25 lines
778 B
Bash
#!/bin/bash
|
|
|
|
# 生成自签名证书
|
|
gen_self_tls() {
|
|
local domain="${1:-bing.com}"
|
|
local script_dir="$(dirname "$(realpath "$0")")"
|
|
local key_dir="$script_dir/../key"
|
|
local config_file="$script_dir/../config.json"
|
|
|
|
# 导入utils文件夹中的jq_util.sh脚本
|
|
source "$script_dir/utils/jq_util.sh"
|
|
|
|
# 生成自签名证书
|
|
openssl req -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) \
|
|
-keyout "$key_dir/server.key" \
|
|
-out "$key_dir/server.crt" \
|
|
-subj "/CN=$domain" \
|
|
-days 36500
|
|
|
|
# 更新config.json文件中的域名信息
|
|
modify_json_file "$config_file" "masquerade.proxy.url" "https://$domain"
|
|
}
|
|
|
|
# 调用函数,传入第一个参数作为域名
|
|
gen_self_tls "${1:-bing.com}" |