feat: 解决部分情况下申请证书超时的问题 (#3540)

Refs https://github.com/1Panel-dev/1Panel/issues/3431
pull/3544/head
zhengkunwang 11 months ago committed by GitHub
parent 47524dc49b
commit c4b7dd70cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,6 +33,7 @@ type WebsiteSSLRenew struct {
type WebsiteSSLApply struct {
ID uint `json:"ID" validate:"required"`
SkipDNSCheck bool `json:"SkipDNSCheck"`
}
type WebsiteAcmeAccountCreate struct {

@ -191,7 +191,7 @@ func (w WebsiteSSLService) ObtainSSL(apply request.WebsiteSSLApply) error {
if err != nil {
return err
}
if err = client.UseDns(ssl.DnsType(dnsAccount.Type), dnsAccount.Authorization); err != nil {
if err = client.UseDns(ssl.DnsType(dnsAccount.Type), dnsAccount.Authorization, apply.SkipDNSCheck); err != nil {
return err
}
case constant.Http:

@ -80,7 +80,7 @@ type DNSParam struct {
APISecret string `json:"apiSecret"`
}
func (c *AcmeClient) UseDns(dnsType DnsType, params string) error {
func (c *AcmeClient) UseDns(dnsType DnsType, params string, skipDNSCheck bool) error {
var (
param DNSParam
p challenge.Provider
@ -150,6 +150,9 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string) error {
if err != nil {
return err
}
if skipDNSCheck {
return c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(10*time.Minute), dns01.DisableCompletePropagationRequirement())
}
return c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(10*time.Minute))
}

@ -1,5 +1,5 @@
// Code generated by swaggo/swag. DO NOT EDIT.
// Package docs GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag
package docs
import "github.com/swaggo/swag"
@ -20489,6 +20489,9 @@ const docTemplate = `{
"properties": {
"ID": {
"type": "integer"
},
"SkipDNSCheck": {
"type": "boolean"
}
}
},

@ -20482,6 +20482,9 @@
"properties": {
"ID": {
"type": "integer"
},
"SkipDNSCheck": {
"type": "boolean"
}
}
},

@ -4358,6 +4358,8 @@ definitions:
properties:
ID:
type: integer
SkipDNSCheck:
type: boolean
required:
- ID
type: object

@ -203,6 +203,7 @@ export namespace Website {
export interface AcmeAccount extends CommonModel {
email: string;
url: string;
type: string;
}
export interface AcmeAccountCreate {
@ -462,6 +463,7 @@ export namespace Website {
export interface SSLObtain {
ID: number;
skipDNSCheck: boolean;
}
export interface CA extends CommonModel {

@ -1926,6 +1926,8 @@ const message = {
"<a target=“_blank” href='https://cloud.google.com/certificate-manager/docs/public-ca-tutorial?hl=zh-cn'>如何取得EAB HmacKey 和EAB kid</a > ",
googleCloudHelper: 'Google Cloud API is not accessible in most parts of mainland China',
httpHelper2: 'Unable to apply for a generic domain name certificate in HTTP mode',
skipDNSCheck: 'Skip DNS check',
skipDNSCheckHelper: 'If there is an application timeout problem, please check here, otherwise do not check it',
},
firewall: {
create: 'Create rule',

@ -1808,6 +1808,8 @@ const message = {
"<a target=“_blank” href='https://cloud.google.com/certificate-manager/docs/public-ca-tutorial?hl=zh-cn'>如何取得EAB HmacKey 和EAB kid</a > ",
googleCloudHelper: 'Google Cloud API ',
httpHelper2: 'HTTP ',
skipDNSCheck: ' DNS ',
skipDNSCheckHelper: '',
},
firewall: {
create: '',

@ -1808,6 +1808,8 @@ const message = {
"<a target=“_blank” href='https://cloud.google.com/certificate-manager/docs/public-ca-tutorial?hl=zh-cn'>如何获取 EAB HmacKey 和 EAB kid</a> ",
googleCloudHelper: 'Google Cloud API 访',
httpHelper2: 'HTTP ',
skipDNSCheck: ' DNS ',
skipDNSCheckHelper: '',
},
firewall: {
create: '',

@ -31,6 +31,11 @@
</el-table>
</div>
<div class="mt-3">
<el-checkbox v-model="skipDNSCheck">{{ $t('ssl.skipDNSCheck') }}</el-checkbox>
<span class="input-help">{{ $t('ssl.skipDNSCheckHelper') }}</span>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
@ -62,11 +67,13 @@ const handleClose = () => {
open.value = false;
em('close', false);
};
const skipDNSCheck = ref(false);
const acceptParams = async (props: RenewProps) => {
open.value = true;
dnsResolve.value = [];
sslID.value = props.ssl.id;
skipDNSCheck.value = false;
getDnsResolve(props.ssl);
};
@ -89,7 +96,7 @@ const getDnsResolve = async (row: Website.SSL) => {
};
const submit = () => {
ObtainSSL({ ID: sslID.value })
ObtainSSL({ ID: sslID.value, skipDNSCheck: skipDNSCheck.value })
.then(() => {
MsgSuccess(i18n.global.t('ssl.applyStart'));
handleClose();

@ -40,9 +40,20 @@
<el-option
v-for="(acme, index) in acmeAccounts"
:key="index"
:label="acme.email"
:label="acme.email + ' [' + getAccountName(acme.type) + '] '"
:value="acme.id"
></el-option>
>
<el-row>
<el-col :span="6">
<span>{{ acme.email }}</span>
</el-col>
<el-col :span="11">
<span>
<el-tag type="success">{{ getAccountName(acme.type) }}</el-tag>
</span>
</el-col>
</el-row>
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('website.keyType')" prop="keyType">
@ -80,7 +91,7 @@
<el-option
v-for="(dns, index) in dnsAccounts"
:key="index"
:label="dns.name"
:label="dns.name + ' [' + getDNSName(dns.type) + '] '"
:value="dns.id"
>
<el-row>
@ -89,7 +100,7 @@
</el-col>
<el-col :span="11">
<span>
<el-tag type="success">{{ dns.type }}</el-tag>
<el-tag type="success">{{ getDNSName(dns.type) }}</el-tag>
</span>
</el-col>
</el-row>
@ -136,6 +147,7 @@ import { FormInstance } from 'element-plus';
import { computed, reactive, ref } from 'vue';
import { MsgSuccess } from '@/utils/message';
import { KeyTypes } from '@/global/mimetype';
import { getDNSName, getAccountName } from '@/utils/util';
const props = defineProps({
id: {

@ -21,6 +21,10 @@
<br />
</div>
<span>{{ $t('ssl.renewConfirm', [ssl.primaryDomain]) }}</span>
<div class="mt-3">
<el-checkbox v-model="skipDNSCheck">{{ $t('ssl.skipDNSCheck') }}</el-checkbox>
<span class="input-help">{{ $t('ssl.skipDNSCheckHelper') }}</span>
</div>
</div>
<template #footer>
<span class="dialog-footer">
@ -52,10 +56,12 @@ const handleClose = () => {
em('close', false);
};
const ssl = ref();
const skipDNSCheck = ref(false);
const acceptParams = async (props: RenewProps) => {
ssl.value = props.ssl;
open.value = true;
skipDNSCheck.value = false;
};
const submit = async () => {
@ -64,7 +70,7 @@ const submit = async () => {
if (ssl.value.provider == 'selfSigned') {
await RenewSSLByCA({ SSLID: ssl.value.id });
} else {
await ObtainSSL({ ID: ssl.value.id });
await ObtainSSL({ ID: ssl.value.id, skipDNSCheck: skipDNSCheck.value });
}
handleClose();
MsgSuccess(i18n.global.t('ssl.applyStart'));

Loading…
Cancel
Save