Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Provide SSL certificate verification options #100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ For the HTTP checks, you can set these attributes:

* **probefilters** - Region from which the check should originate. One of NA, EU, APAC, or LATAM. Should be in the format "region:NA"

* **verifycertificate** - Enable monitoring of SSL/TLS certificate.

* **ssldowndaysbefore** - Days prior to certificate expiring to consider down.

#### TCP specific attributes ####

For the TCP checks, you can set these attributes:
Expand Down
28 changes: 28 additions & 0 deletions pingdom/resource_pingdom_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ func resourcePingdomCheck() *schema.Resource {
Optional: true,
ForceNew: false,
},
"verifycertificate": {
Type: schema.TypeBool,
Optional: true,
ForceNew: false,
},
"ssldowndaysbefore": {
Type: schema.TypeInt,
Optional: true,
ForceNew: false,
},
},
}
}
Expand Down Expand Up @@ -210,6 +220,8 @@ type commonCheckParams struct {
ProbeFilters string
StringToSend string
StringToExpect string
VerifyCertificate bool
SSLDownDaysBefore int
}

func sortString(input string, seperator string) string {
Expand Down Expand Up @@ -335,6 +347,14 @@ func checkForResource(d *schema.ResourceData) (pingdom.Check, error) {
checkParams.StringToExpect = v.(string)
}

if v, ok := d.GetOk("verifycertificate"); ok {
checkParams.VerifyCertificate = v.(bool)
}

if v, ok := d.GetOk("ssldowndaysbefore"); ok {
checkParams.SSLDownDaysBefore = v.(int)
}

checkType := d.Get("type")
switch checkType {
case "http":
Expand All @@ -361,6 +381,8 @@ func checkForResource(d *schema.ResourceData) (pingdom.Check, error) {
ProbeFilters: checkParams.ProbeFilters,
UserIds: checkParams.UserIds,
TeamIds: checkParams.TeamIds,
VerifyCertificate: &checkParams.VerifyCertificate,
SSLDownDaysBefore: &checkParams.SSLDownDaysBefore,
}, nil
case "ping":
return &pingdom.PingCheck{
Expand Down Expand Up @@ -565,6 +587,12 @@ func resourcePingdomCheckRead(d *schema.ResourceData, meta interface{}) error {
if err := d.Set("postdata", ck.Type.HTTP.PostData); err != nil {
return err
}
if err := d.Set("verifycertificate", ck.Type.HTTP.VerifyCertificate); err != nil {
return err
}
if err := d.Set("ssldowndaysbefore", ck.Type.HTTP.SSLDownDaysBefore); err != nil {
return err
}

if v, ok := ck.Type.HTTP.RequestHeaders["User-Agent"]; ok {
if strings.HasPrefix(v, "Pingdom.com_bot_version_") {
Expand Down