@@ -14,6 +14,7 @@ import (
1414 "github.com/go-acme/lego/v4/providers/dns/internal/useragent"
1515 selectelapi "github.com/selectel/domains-go/pkg/v2"
1616 "github.com/selectel/go-selvpcclient/v3/selvpcclient"
17+ "golang.org/x/net/idna"
1718)
1819
1920const tokenHeader = "X-Auth-Token"
@@ -252,21 +253,26 @@ type clientWrapper struct {
252253}
253254
254255func (w * clientWrapper ) getZone (ctx context.Context , name string ) (* selectelapi.Zone , error ) {
255- params := & map [string ]string {"filter" : name }
256+ unicodeName , err := idna .ToUnicode (name )
257+ if err != nil {
258+ return nil , fmt .Errorf ("to unicode: %w" , err )
259+ }
260+
261+ params := & map [string ]string {"filter" : unicodeName }
256262
257263 zones , err := w .ListZones (ctx , params )
258264 if err != nil {
259265 return nil , fmt .Errorf ("list zone: %w" , err )
260266 }
261267
262268 for _ , zone := range zones .GetItems () {
263- if zone .Name == dns01 .ToFqdn (name ) {
269+ if zone .Name == dns01 .ToFqdn (unicodeName ) {
264270 return zone , nil
265271 }
266272 }
267273
268274 if len (strings .Split (dns01 .UnFqdn (name ), "." )) == 1 {
269- return nil , errors . New ("zone for challenge has not been found" )
275+ return nil , fmt . Errorf ("zone '%s' for challenge has not been found" , name )
270276 }
271277
272278 // -1 can not be returned since if no dots present we exit above
@@ -276,15 +282,20 @@ func (w *clientWrapper) getZone(ctx context.Context, name string) (*selectelapi.
276282}
277283
278284func (w * clientWrapper ) getRRset (ctx context.Context , name , zoneID string ) (* selectelapi.RRSet , error ) {
279- params := & map [string ]string {"name" : name , "rrset_types" : string (selectelapi .TXT )}
285+ unicodeName , err := idna .ToUnicode (name )
286+ if err != nil {
287+ return nil , fmt .Errorf ("to unicode: %w" , err )
288+ }
289+
290+ params := & map [string ]string {"name" : unicodeName , "rrset_types" : string (selectelapi .TXT )}
280291
281292 resp , err := w .ListRRSets (ctx , zoneID , params )
282293 if err != nil {
283294 return nil , fmt .Errorf ("list rrset: %w" , err )
284295 }
285296
286297 for _ , rrset := range resp .GetItems () {
287- if rrset .Name == dns01 .ToFqdn (name ) {
298+ if rrset .Name == dns01 .ToFqdn (unicodeName ) {
288299 return rrset , nil
289300 }
290301 }
0 commit comments