diff --git a/docs/content/dns/zz_gen_selectelv2.md b/docs/content/dns/zz_gen_selectelv2.md index dba55a44..857e3d83 100644 --- a/docs/content/dns/zz_gen_selectelv2.md +++ b/docs/content/dns/zz_gen_selectelv2.md @@ -26,10 +26,10 @@ Configuration for [Selectel v2](https://selectel.ru). Here is an example bash command using the Selectel v2 provider: ```bash -SELECTEL_USERNAME=trex \ -SELECTEL_PASSWORD=xxxxx \ -SELECTEL_ACCOUNT_ID=1234567 \ -SELECTEL_PROJECT_ID=111a11111aaa11aa1a11aaa11111aa1a \ +SELECTELV2_USERNAME=trex \ +SELECTELV2_PASSWORD=xxxxx \ +SELECTELV2_ACCOUNT_ID=1234567 \ +SELECTELV2_PROJECT_ID=111a11111aaa11aa1a11aaa11111aa1a \ lego --email you@example.com --dns selectelv2 --domains my.example.org run ``` diff --git a/providers/dns/selectelv2/selectelv2.go b/providers/dns/selectelv2/selectelv2.go index 8e114e24..f5bd10c9 100644 --- a/providers/dns/selectelv2/selectelv2.go +++ b/providers/dns/selectelv2/selectelv2.go @@ -14,6 +14,7 @@ import ( "github.com/go-acme/lego/v4/providers/dns/internal/useragent" selectelapi "github.com/selectel/domains-go/pkg/v2" "github.com/selectel/go-selvpcclient/v3/selvpcclient" + "golang.org/x/net/idna" ) const tokenHeader = "X-Auth-Token" @@ -252,7 +253,12 @@ type clientWrapper struct { } func (w *clientWrapper) getZone(ctx context.Context, name string) (*selectelapi.Zone, error) { - params := &map[string]string{"filter": name} + unicodeName, err := idna.ToUnicode(name) + if err != nil { + return nil, fmt.Errorf("to unicode: %w", err) + } + + params := &map[string]string{"filter": unicodeName} zones, err := w.ListZones(ctx, params) if err != nil { @@ -260,13 +266,13 @@ func (w *clientWrapper) getZone(ctx context.Context, name string) (*selectelapi. } for _, zone := range zones.GetItems() { - if zone.Name == dns01.ToFqdn(name) { + if zone.Name == dns01.ToFqdn(unicodeName) { return zone, nil } } if len(strings.Split(dns01.UnFqdn(name), ".")) == 1 { - return nil, errors.New("zone for challenge has not been found") + return nil, fmt.Errorf("zone '%s' for challenge has not been found", name) } // -1 can not be returned since if no dots present we exit above @@ -276,7 +282,12 @@ func (w *clientWrapper) getZone(ctx context.Context, name string) (*selectelapi. } func (w *clientWrapper) getRRset(ctx context.Context, name, zoneID string) (*selectelapi.RRSet, error) { - params := &map[string]string{"name": name, "rrset_types": string(selectelapi.TXT)} + unicodeName, err := idna.ToUnicode(name) + if err != nil { + return nil, fmt.Errorf("to unicode: %w", err) + } + + params := &map[string]string{"name": unicodeName, "rrset_types": string(selectelapi.TXT)} resp, err := w.ListRRSets(ctx, zoneID, params) if err != nil { @@ -284,7 +295,7 @@ func (w *clientWrapper) getRRset(ctx context.Context, name, zoneID string) (*sel } for _, rrset := range resp.GetItems() { - if rrset.Name == dns01.ToFqdn(name) { + if rrset.Name == dns01.ToFqdn(unicodeName) { return rrset, nil } } diff --git a/providers/dns/selectelv2/selectelv2.toml b/providers/dns/selectelv2/selectelv2.toml index 7870688b..b157c112 100644 --- a/providers/dns/selectelv2/selectelv2.toml +++ b/providers/dns/selectelv2/selectelv2.toml @@ -5,10 +5,10 @@ Code = "selectelv2" Since = "v4.17.0" Example = ''' -SELECTEL_USERNAME=trex \ -SELECTEL_PASSWORD=xxxxx \ -SELECTEL_ACCOUNT_ID=1234567 \ -SELECTEL_PROJECT_ID=111a11111aaa11aa1a11aaa11111aa1a \ +SELECTELV2_USERNAME=trex \ +SELECTELV2_PASSWORD=xxxxx \ +SELECTELV2_ACCOUNT_ID=1234567 \ +SELECTELV2_PROJECT_ID=111a11111aaa11aa1a11aaa11111aa1a \ lego --email you@example.com --dns selectelv2 --domains my.example.org run '''