@@ -14,6 +14,7 @@ import (
14
14
"github.com/go-acme/lego/v4/providers/dns/internal/useragent"
15
15
selectelapi "github.com/selectel/domains-go/pkg/v2"
16
16
"github.com/selectel/go-selvpcclient/v3/selvpcclient"
17
+ "golang.org/x/net/idna"
17
18
)
18
19
19
20
const tokenHeader = "X-Auth-Token"
@@ -252,21 +253,26 @@ type clientWrapper struct {
252
253
}
253
254
254
255
func (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 }
256
262
257
263
zones , err := w .ListZones (ctx , params )
258
264
if err != nil {
259
265
return nil , fmt .Errorf ("list zone: %w" , err )
260
266
}
261
267
262
268
for _ , zone := range zones .GetItems () {
263
- if zone .Name == dns01 .ToFqdn (name ) {
269
+ if zone .Name == dns01 .ToFqdn (unicodeName ) {
264
270
return zone , nil
265
271
}
266
272
}
267
273
268
274
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 )
270
276
}
271
277
272
278
// -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.
276
282
}
277
283
278
284
func (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 )}
280
291
281
292
resp , err := w .ListRRSets (ctx , zoneID , params )
282
293
if err != nil {
283
294
return nil , fmt .Errorf ("list rrset: %w" , err )
284
295
}
285
296
286
297
for _ , rrset := range resp .GetItems () {
287
- if rrset .Name == dns01 .ToFqdn (name ) {
298
+ if rrset .Name == dns01 .ToFqdn (unicodeName ) {
288
299
return rrset , nil
289
300
}
290
301
}
0 commit comments