Skip to content

Commit

Permalink
Separate SSL success and warning alert messages (#7736)
Browse files Browse the repository at this point in the history
* Separated warning and success alert messages

* removed redundant message
  • Loading branch information
ericholguin authored Aug 23, 2023
1 parent c59d011 commit a0f6b1f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions traffic_ops/traffic_ops_golang/deliveryservice/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,27 @@ func AddSSLKeys(w http.ResponseWriter, r *http.Request) {

api.CreateChangeLogRawTx(api.ApiChange, "DS: "+*req.DeliveryService+", ID: "+strconv.Itoa(dsID)+", ACTION: Added/Updated SSL keys", inf.User, inf.Tx.Tx)

var alerts tc.Alerts

if isUnknownAuth {
api.WriteRespAlert(w, r, tc.WarnLevel, "WARNING: SSL keys were successfully added for '"+*req.DeliveryService+"', but the input certificate may be invalid (certificate is signed by an unknown authority)")
return
alerts.AddAlert(tc.Alert{
Text: "The input certificate may be invalid for '" + *req.DeliveryService + "' (certificate is signed by an unknown authority)",
Level: tc.WarnLevel.String(),
})
}
if isVerifiedChainNotEqual {
api.WriteRespAlert(w, r, tc.WarnLevel, "WARNING: SSL keys were successfully added for '"+*req.DeliveryService+"', but the input certificate may be invalid (certificate verification produced a different chain)")
return
alerts.AddAlert(tc.Alert{
Text: "The input certificate may be invalid for '" + *req.DeliveryService + "' (certificate verification produced a different chain)",
Level: tc.WarnLevel.String(),
})
}

api.WriteRespAlert(w, r, tc.SuccessLevel, "Successfully added ssl keys for "+*req.DeliveryService)
alerts.AddAlert(tc.Alert{
Text: "Added ssl keys for " + *req.DeliveryService,
Level: tc.SuccessLevel.String(),
})

api.WriteAlerts(w, r, http.StatusOK, alerts)
}

// GetSSlKeyExpirationInformation gets expiration information for all SSL certificates.
Expand Down

0 comments on commit a0f6b1f

Please sign in to comment.