mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-05 05:54:53 +00:00
feat: add azure dns applicant
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package aws
|
||||
package awsroute53
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/go-acme/lego/v4/providers/dns/route53"
|
||||
)
|
||||
|
||||
type AWSApplicantConfig struct {
|
||||
type AWSRoute53ApplicantConfig struct {
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
SecretAccessKey string `json:"secretAccessKey"`
|
||||
Region string `json:"region"`
|
||||
@@ -16,7 +16,7 @@ type AWSApplicantConfig struct {
|
||||
PropagationTimeout int32 `json:"propagationTimeout,omitempty"`
|
||||
}
|
||||
|
||||
func NewChallengeProvider(config *AWSApplicantConfig) (challenge.Provider, error) {
|
||||
func NewChallengeProvider(config *AWSRoute53ApplicantConfig) (challenge.Provider, error) {
|
||||
if config == nil {
|
||||
return nil, errors.New("config is nil")
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package azuredns
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
|
||||
"github.com/go-acme/lego/v4/challenge"
|
||||
"github.com/go-acme/lego/v4/providers/dns/azuredns"
|
||||
)
|
||||
|
||||
type AzureDNSApplicantConfig struct {
|
||||
TenantId string `json:"tenantId"`
|
||||
ClientId string `json:"clientId"`
|
||||
ClientSecret string `json:"clientSecret"`
|
||||
CloudName string `json:"cloudName,omitempty"`
|
||||
PropagationTimeout int32 `json:"propagationTimeout,omitempty"`
|
||||
}
|
||||
|
||||
func NewChallengeProvider(config *AzureDNSApplicantConfig) (challenge.Provider, error) {
|
||||
if config == nil {
|
||||
return nil, errors.New("config is nil")
|
||||
}
|
||||
|
||||
providerConfig := azuredns.NewDefaultConfig()
|
||||
providerConfig.TenantID = config.TenantId
|
||||
providerConfig.ClientID = config.ClientId
|
||||
providerConfig.ClientSecret = config.ClientSecret
|
||||
if config.CloudName != "" {
|
||||
switch strings.ToLower(config.CloudName) {
|
||||
case "default", "public", "cloud", "azurecloud":
|
||||
providerConfig.Environment = cloud.AzurePublic
|
||||
case "usgovernment", "azureusgovernment":
|
||||
providerConfig.Environment = cloud.AzureGovernment
|
||||
case "china", "chinacloud", "azurechina", "azurechinacloud":
|
||||
providerConfig.Environment = cloud.AzureChina
|
||||
default:
|
||||
return nil, fmt.Errorf("azuredns: unknown environment %s", config.CloudName)
|
||||
}
|
||||
}
|
||||
if config.PropagationTimeout != 0 {
|
||||
providerConfig.PropagationTimeout = time.Duration(config.PropagationTimeout) * time.Second
|
||||
}
|
||||
|
||||
provider, err := azuredns.NewDNSProviderConfig(providerConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return provider, nil
|
||||
}
|
Reference in New Issue
Block a user