自动准备初始化证书目录并在提交前校验代理入口
This commit is contained in:
1 parent
d174fb66e0
commit
176bf6ed6b
21 files changed
+889
-12
No files matched your search
@@ -587,6 +587,10 @@ export function useSetupWizard(props, emit) {
|
||||
error.value = "代理公开 HTTPS 端口必须为 1 至 65535 的整数。";
|
||||
return false;
|
||||
}
|
||||
if (isBootstrap && (form.value.acme_environment !== "production" || !form.value.web_hostname.trim())) {
|
||||
error.value = "反向代理管理入口需要管理域名和正式环境证书。测试环境或 IP 自签名证书请使用直接 HTTPS 模式,避免初始化后出现 502。";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!form.value.certificate_root.trim()) {
|
||||
error.value = "请填写证书部署根目录。";
|
||||
|
||||
@@ -733,7 +733,7 @@ const {
|
||||
<span>
|
||||
证书部署根目录
|
||||
<HelpTip>
|
||||
可填写服务器上的绝对路径。Scert 运行账户必须有写入权限;Linux 自定义目录还需位于服务的可写范围内。
|
||||
填写服务器绝对路径,缺失目录将自动创建。Linux 会通过本机目录服务配置最小写入权限;支持 /ssl、/var/lib/scert/certificates 及安装时批准的存储范围,不接管其他账户或系统目录。
|
||||
</HelpTip>
|
||||
</span>
|
||||
<input
|
||||
@@ -745,12 +745,11 @@ const {
|
||||
/>
|
||||
</label>
|
||||
<label v-if="isBootstrap">
|
||||
<span>证书签发环境</span>
|
||||
<span>证书签发环境<HelpTip>反向代理管理入口需要正式域名证书。测试证书仅用于直接 HTTPS 测试,浏览器不会公共信任该证书。</HelpTip></span>
|
||||
<select v-model="form.acme_environment">
|
||||
<option value="staging">测试环境(证书不受公共信任)</option>
|
||||
<option value="production">正式环境(实际申请受信任域名证书)</option>
|
||||
</select>
|
||||
<small>IP 管理入口使用自签名证书,不会因选择正式环境而自动受信任。</small>
|
||||
</label>
|
||||
<label>
|
||||
<span>HTTPS 模式</span>
|
||||
|
||||
@@ -11,6 +11,12 @@ test("代理模式提交公开端口并跳转至对应入口", async (t) => {
|
||||
const address = "https://admin.example.test:8004/";
|
||||
const { state, submitted, emitted } = await setup(t, () => Response.json({ completed: true, management_url: address }));
|
||||
state.form.value.https_mode = "proxy";
|
||||
state.form.value.acme_environment = "production";
|
||||
state.form.value.web_hostname = "admin.example.test";
|
||||
state.form.value.web_public_ip = "";
|
||||
state.targetType.value = "hostname";
|
||||
state.dnsTestDomain.value = "admin.example.test";
|
||||
await state.testDNS();
|
||||
state.form.value.proxy_https_port = 8004;
|
||||
state.currentStep.value = 4;
|
||||
await state.handleSubmit();
|
||||
@@ -30,6 +36,17 @@ for (const port of [0, -1, 65536, 8004.5, ""]) {
|
||||
});
|
||||
}
|
||||
|
||||
test("测试环境代理模式在提交前阻止不受信任的管理证书", async (t) => {
|
||||
const { state, submitted } = await setup(t);
|
||||
state.form.value.https_mode = "proxy";
|
||||
state.form.value.proxy_https_port = 443;
|
||||
state.form.value.acme_environment = "staging";
|
||||
state.currentStep.value = 4;
|
||||
await state.handleSubmit();
|
||||
assert.equal(submitted.length, 0);
|
||||
assert.match(state.error.value, /正式环境证书/);
|
||||
});
|
||||
|
||||
async function setup(t, complete = completion, driver = "sqlite") {
|
||||
const submitted = [];
|
||||
const emitted = [];
|
||||
|
||||
Reference in new issue
Block a user