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

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

@ -191,7 +191,7 @@ func (w WebsiteSSLService) ObtainSSL(apply request.WebsiteSSLApply) error {
if err != nil { if err != nil {
return err 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 return err
} }
case constant.Http: case constant.Http:

@ -80,7 +80,7 @@ type DNSParam struct {
APISecret string `json:"apiSecret"` 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 ( var (
param DNSParam param DNSParam
p challenge.Provider p challenge.Provider
@ -150,6 +150,9 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string) error {
if err != nil { if err != nil {
return err 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)) 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 package docs
import "github.com/swaggo/swag" import "github.com/swaggo/swag"
@ -20489,6 +20489,9 @@ const docTemplate = `{
"properties": { "properties": {
"ID": { "ID": {
"type": "integer" "type": "integer"
},
"SkipDNSCheck": {
"type": "boolean"
} }
} }
}, },

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

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

@ -203,6 +203,7 @@ export namespace Website {
export interface AcmeAccount extends CommonModel { export interface AcmeAccount extends CommonModel {
email: string; email: string;
url: string; url: string;
type: string;
} }
export interface AcmeAccountCreate { export interface AcmeAccountCreate {
@ -462,6 +463,7 @@ export namespace Website {
export interface SSLObtain { export interface SSLObtain {
ID: number; ID: number;
skipDNSCheck: boolean;
} }
export interface CA extends CommonModel { 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 > ", "<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', 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', 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: { firewall: {
create: 'Create rule', 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 > ", "<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 ', googleCloudHelper: 'Google Cloud API ',
httpHelper2: 'HTTP ', httpHelper2: 'HTTP ',
skipDNSCheck: ' DNS ',
skipDNSCheckHelper: '',
}, },
firewall: { firewall: {
create: '', 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> ", "<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 访', googleCloudHelper: 'Google Cloud API 访',
httpHelper2: 'HTTP ', httpHelper2: 'HTTP ',
skipDNSCheck: ' DNS ',
skipDNSCheckHelper: '',
}, },
firewall: { firewall: {
create: '', create: '',

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

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

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

Loading…
Cancel
Save