Skip to content

Commit

Permalink
chore: use UTC instead of GMT when possible (#2275)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Sep 16, 2024
1 parent d52f7b0 commit 0da0942
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
9 changes: 2 additions & 7 deletions providers/dns/brandit/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,12 @@ func (c *Client) do(ctx context.Context, query url.Values, result any) error {
}

func sign(apiUsername, apiKey string, query url.Values) (url.Values, error) {
location, err := time.LoadLocation("GMT")
if err != nil {
return nil, fmt.Errorf("time location: %w", err)
}

timestamp := time.Now().In(location).Format("2006-01-02T15:04:05Z")
timestamp := time.Now().UTC().Format("2006-01-02T15:04:05Z")

canonicalRequest := fmt.Sprintf("%s%s%s", apiUsername, timestamp, defaultBaseURL)

mac := hmac.New(sha256.New, []byte(apiKey))
_, err = mac.Write([]byte(canonicalRequest))
_, err := mac.Write([]byte(canonicalRequest))
if err != nil {
return nil, err
}
Expand Down
7 changes: 1 addition & 6 deletions providers/dns/nifcloud/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,7 @@ func (c *Client) do(req *http.Request, result any) error {

func (c *Client) sign(req *http.Request) error {
if req.Header.Get("Date") == "" {
location, err := time.LoadLocation("GMT")
if err != nil {
return err
}

req.Header.Set("Date", time.Now().In(location).Format(time.RFC1123))
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
}

if req.URL.Path == "" {
Expand Down
7 changes: 1 addition & 6 deletions providers/dns/websupport/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,7 @@ func (c *Client) DeleteRecord(ctx context.Context, domainName string, recordID i
func (c *Client) do(req *http.Request, result any) error {
req.Header.Set("Accept-Language", "en_us")

location, err := time.LoadLocation("GMT")
if err != nil {
return fmt.Errorf("time location: %w", err)
}

err = c.sign(req, time.Now().In(location))
err := c.sign(req, time.Now().UTC())
if err != nil {
return fmt.Errorf("signature: %w", err)
}
Expand Down

0 comments on commit 0da0942

Please sign in to comment.