mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 解决手动解析模式 申请证书失败的BUG
This commit is contained in:
parent
355a6b0205
commit
59b025353f
@ -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 {
|
if err := client.UseHTTP(path.Join(constant.AppInstallDir, constant.AppOpenresty, appInstall.Name, "root")); err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
case constant.DnsManual:
|
||||||
|
if err := client.UseManualDns(); err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
domains := []string{create.PrimaryDomain}
|
domains := []string{create.PrimaryDomain}
|
||||||
|
@ -89,6 +89,7 @@ func NewPrivateKeyClient(email string, privateKey string) (*AcmeClient, error) {
|
|||||||
func newConfig(user *AcmeUser) *lego.Config {
|
func newConfig(user *AcmeUser) *lego.Config {
|
||||||
config := lego.NewConfig(user)
|
config := lego.NewConfig(user)
|
||||||
config.CADirURL = "https://acme-v02.api.letsencrypt.org/directory"
|
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.UserAgent = "acm_go/0.0.1"
|
||||||
config.Certificate.KeyType = certcrypto.RSA2048
|
config.Certificate.KeyType = certcrypto.RSA2048
|
||||||
return config
|
return config
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-acme/lego/v4/acme/api"
|
"github.com/go-acme/lego/v4/acme/api"
|
||||||
"github.com/go-acme/lego/v4/certcrypto"
|
"github.com/go-acme/lego/v4/certcrypto"
|
||||||
@ -154,10 +155,10 @@ func TestSSL(t *testing.T) {
|
|||||||
// panic(err)
|
// panic(err)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// err = client.Challenge.SetDNS01Provider(&plainDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
|
err = client.Challenge.SetDNS01Provider(&manualDnsProvider{}, dns01.AddDNSTimeout(6*time.Minute))
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// panic(err)
|
panic(err)
|
||||||
// }
|
}
|
||||||
|
|
||||||
core, err := api.New(config.HTTPClient, config.UserAgent, config.CADirURL, reg.URI, priKey)
|
core, err := api.New(config.HTTPClient, config.UserAgent, config.CADirURL, reg.URI, priKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -115,22 +115,12 @@ func (c *AcmeClient) UseDns(dnsType DnsType, params string) error {
|
|||||||
return c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(3*time.Minute))
|
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{}
|
p := &manualDnsProvider{}
|
||||||
if err := c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(3*time.Minute)); err != nil {
|
if err := c.Client.Challenge.SetDNS01Provider(p, dns01.AddDNSTimeout(3*time.Minute)); err != nil {
|
||||||
return nil, nil
|
return err
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
request := certificate.ObtainRequest{
|
|
||||||
Domains: domains,
|
|
||||||
Bundle: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := c.Client.Certificate.Obtain(request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return p.Resolve, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AcmeClient) UseHTTP(path string) error {
|
func (c *AcmeClient) UseHTTP(path string) error {
|
||||||
|
@ -996,7 +996,7 @@ export default {
|
|||||||
addAccount: 'Add new account',
|
addAccount: 'Add new account',
|
||||||
acmeAccount: 'Acme Account',
|
acmeAccount: 'Acme Account',
|
||||||
provider: 'Verification method',
|
provider: 'Verification method',
|
||||||
dnsCommon: 'Manual resolution',
|
dnsManual: 'Manual resolution',
|
||||||
expireDate: 'Expiration Time',
|
expireDate: 'Expiration Time',
|
||||||
brand: 'Issuer',
|
brand: 'Issuer',
|
||||||
deploySSL: 'Deployment',
|
deploySSL: 'Deployment',
|
||||||
|
@ -1004,7 +1004,7 @@ export default {
|
|||||||
addAccount: '创建账户',
|
addAccount: '创建账户',
|
||||||
acmeAccount: 'Acme 账户',
|
acmeAccount: 'Acme 账户',
|
||||||
provider: '验证方式',
|
provider: '验证方式',
|
||||||
dnsCommon: '手动解析',
|
dnsManual: '手动解析',
|
||||||
expireDate: '过期时间',
|
expireDate: '过期时间',
|
||||||
brand: '颁发者',
|
brand: '颁发者',
|
||||||
deploySSL: '部署',
|
deploySSL: '部署',
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<el-form-item :label="$t('website.provider')" prop="provider">
|
<el-form-item :label="$t('website.provider')" prop="provider">
|
||||||
<el-radio-group v-model="ssl.provider" @change="changeProvider()">
|
<el-radio-group v-model="ssl.provider" @change="changeProvider()">
|
||||||
<el-radio label="dnsAccount">{{ $t('website.dnsAccount') }}</el-radio>
|
<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 label="http">HTTP</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user