Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
fix: domain check for wildcard.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Mar 3, 2020
1 parent f4cbfcd commit 01f66d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const successMsg = "The certificate currently available on %s is OK."

// IsSafe check if a domain is safe.
func IsSafe(domain string, debug bool) (bool, error) {
trimmed := strings.TrimPrefix(domain, "*.")

values := url.Values{}
values.Set("fqdn", strings.TrimPrefix(domain, "*."))
values.Set("fqdn", trimmed)

resp, err := http.DefaultClient.PostForm("https://unboundtest.com/caaproblem/checkhost", values)
if err != nil {
Expand All @@ -35,5 +37,5 @@ func IsSafe(domain string, debug bool) (bool, error) {
log.Println("Response:", string(all))
}

return strings.Contains(string(all), fmt.Sprintf(successMsg, domain)), nil
return strings.Contains(string(all), fmt.Sprintf(successMsg, trimmed)), nil
}

0 comments on commit 01f66d7

Please sign in to comment.