fix: 解决手动解析模式 申请证书失败的BUG

This commit is contained in:
zhengkunwang223 2023-03-16 18:44:32 +08:00 committed by f2c-ci-robot[bot]
parent 355a6b0205
commit 59b025353f
7 changed files with 16 additions and 20 deletions

View File

@ -99,6 +99,10 @@ func (w WebsiteSSLService) Create(create request.WebsiteSSLCreate) (request.Webs
if err := client.UseHTTP(path.Join(constant.AppInstallDir, constant.AppOpenresty, appInstall.Name, "root")); err != nil {
return res, err
}
case constant.DnsManual:
if err := client.UseManualDns(); err != nil {
return res, err
}
}
domains := []string{create.PrimaryDomain}

View File

@ -89,6 +89,7 @@ func NewPrivateKeyClient(email string, privateKey string) (*AcmeClient, error) {
func newConfig(user *AcmeUser) *lego.Config {
config := lego.NewConfig(user)
config.CADirURL = "https://acme-v02.api.letsencrypt.org/directory"
//config.CADirURL = "https://acme-staging-v02.api.letsencrypt.org/directory"
config.UserAgent = "acm_go/0.0.1"
config.Certificate.KeyType = certcrypto.RSA2048
return config

View File

@ -9,6 +9,7 @@ import (
"io/ioutil"
"os"
"testing"
"time"
"github.com/go-acme/lego/v4/acme/api"
"github.com/go-acme/lego/v4/certcrypto"
@ -154,10 +155,10 @@ func TestSSL(t *testing.T) {
// panic(err)
//}
// err = client.Challenge.SetDNS01Provider(&plainDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
// if err != nil {
// panic(err)
// }
err = client.Challenge.SetDNS01Provider(&manualDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
if err != nil {
panic(err)
}
core, err := api.New(config.HTTPClient, config.UserAgent, config.CADirURL, reg.URI, priKey)
if err != nil {

View File

@ -115,22 +115,12 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string) error {
return c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(3*time.Minute))
}
func (c *AcmeClient) UseManualDns(domains []string) (*Resolve, error) {
func (c *AcmeClient) UseManualDns() error {
p := &manualDnsProvider{}
if err := c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(3*time.Minute)); err != nil {
return nil, nil
return err
}
request := certificate.ObtainRequest{
Domains: domains,
Bundle: true,
}
_, err := c.Client.Certificate.Obtain(request)
if err != nil {
return nil, err
}
return p.Resolve, nil
return nil
}
func (c *AcmeClient) UseHTTP(path string) error {

View File

@ -996,7 +996,7 @@ export default {
addAccount: 'Add new account',
acmeAccount: 'Acme Account',
provider: 'Verification method',
dnsCommon: 'Manual resolution',
dnsManual: 'Manual resolution',
expireDate: 'Expiration Time',
brand: 'Issuer',
deploySSL: 'Deployment',

View File

@ -1004,7 +1004,7 @@ export default {
addAccount: '创建账户',
acmeAccount: 'Acme 账户',
provider: '验证方式',
dnsCommon: '手动解析',
dnsManual: '手动解析',
expireDate: '过期时间',
brand: '颁发者',
deploySSL: '部署',

View File

@ -29,7 +29,7 @@
<el-form-item :label="$t('website.provider')" prop="provider">
<el-radio-group v-model="ssl.provider" @change="changeProvider()">
<el-radio label="dnsAccount">{{ $t('website.dnsAccount') }}</el-radio>
<el-radio label="dnsManual">{{ $t('website.dnsCommon') }}</el-radio>
<el-radio label="dnsManual">{{ $t('website.dnsManual') }}</el-radio>
<el-radio label="http">HTTP</el-radio>
</el-radio-group>
</el-form-item>