diff --git a/backend/app/service/website_ssl.go b/backend/app/service/website_ssl.go index c1d745100..576d5c5d9 100644 --- a/backend/app/service/website_ssl.go +++ b/backend/app/service/website_ssl.go @@ -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} diff --git a/backend/utils/ssl/acme.go b/backend/utils/ssl/acme.go index 110d6c171..8e9763805 100644 --- a/backend/utils/ssl/acme.go +++ b/backend/utils/ssl/acme.go @@ -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 diff --git a/backend/utils/ssl/acme_test.go b/backend/utils/ssl/acme_test.go index 09d0ac5f1..af9b05129 100644 --- a/backend/utils/ssl/acme_test.go +++ b/backend/utils/ssl/acme_test.go @@ -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 { diff --git a/backend/utils/ssl/client.go b/backend/utils/ssl/client.go index ce1d985ba..b1a465a6d 100644 --- a/backend/utils/ssl/client.go +++ b/backend/utils/ssl/client.go @@ -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 { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 00f921475..2641238ab 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -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', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 55cafbfd6..c18813d8e 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1004,7 +1004,7 @@ export default { addAccount: '创建账户', acmeAccount: 'Acme 账户', provider: '验证方式', - dnsCommon: '手动解析', + dnsManual: '手动解析', expireDate: '过期时间', brand: '颁发者', deploySSL: '部署', diff --git a/frontend/src/views/website/ssl/create/index.vue b/frontend/src/views/website/ssl/create/index.vue index 66ffec3b3..c0261ac54 100644 --- a/frontend/src/views/website/ssl/create/index.vue +++ b/frontend/src/views/website/ssl/create/index.vue @@ -29,7 +29,7 @@ {{ $t('website.dnsAccount') }} - {{ $t('website.dnsCommon') }} + {{ $t('website.dnsManual') }} HTTP