Skip to content

Commit

Permalink
Revert "Fix status code and alert structure for sslkeys endpoint, whe…
Browse files Browse the repository at this point in the history
…n no ssl keys are present. (#7595)"

This reverts commit 1e39991.
  • Loading branch information
zrhoffman committed Jul 11, 2023
1 parent c6fcfea commit 7d5cebe
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7425](https://github.com/apache/trafficcontrol/pull/7425) *Traffic Control Cache Config (t3c)* Fixed issue with layered profile iteration being done in the wrong order.
- [#6385](https://github.com/apache/trafficcontrol/issues/6385) *Traffic Ops* Reserved consistentHashQueryParameters cause internal server error
- [#7471](https://github.com/apache/trafficcontrol/pull/7471) *Traffic Control Cache Config (t3c)* Fixed issue with MSO non topo origins from multiple cache groups.
- [#4393](https://github.com/apache/trafficcontrol/issues/4393) *Traffic Ops* Fixed the error code and alert structure when TO is queried for a delivery service with no ssl keys.
- [#7590](https://github.com/apache/trafficcontrol/issues/7590) *Traffic Control Cache Config (t3c)* Fixed issue with git detected dubious ownership in repository.
- [#7575](https://github.com/apache/trafficcontrol/pull/7575) *Traffic Ops* Fixes `types` v5 apis to respond with `RFC3339` date/time Format.
- [#7628](https://github.com/apache/trafficcontrol/pull/7628) *Traffic Ops* Fixes an issue where certificate chain validation failed based on leading or trailing whitespace.
Expand Down
1 change: 1 addition & 0 deletions traffic_ops/testing/api/v5/deliveryservices_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ func VerifySSLKeysOnDsCreationTest(t *testing.T) {
break
}
}

if err != nil || dsSSLKey == nil {
t.Fatalf("unable to get DS %s SSL key: %v", ds.XMLID, err)
}
Expand Down
25 changes: 4 additions & 21 deletions traffic_ops/traffic_ops_golang/deliveryservice/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,12 @@ func GetSSLKeysByXMLID(w http.ResponseWriter, r *http.Request) {
return
}

var userError error
sc := http.StatusInternalServerError
logAlert := true
keyObjV4, err := getSslKeys(inf, r.Context())
if err != nil {
userError = api.LogErr(r, sc, nil, err)
if err == sql.ErrNoRows {
if inf.Version.GreaterThanOrEqualTo(&api.Version{Major: 5, Minor: 0}) {
sc = http.StatusNotFound
userError = api.LogErr(r, sc, errors.New("no ssl keys for XML ID "+xmlID), nil)
} else {
// For versions lesser than 5.0, don't log an alert if the error is ErrNoRows. This is for backward compatibility reasons.
logAlert = false
}
}
if logAlert {
alerts.AddNewAlert(tc.ErrorLevel, userError.Error())
api.WriteAlerts(w, r, sc, alerts)
return
}
userErr := api.LogErr(r, http.StatusInternalServerError, nil, err)
alerts.AddNewAlert(tc.ErrorLevel, userErr.Error())
api.WriteAlerts(w, r, http.StatusInternalServerError, alerts)
return
}

var keyObj interface{}
Expand All @@ -230,9 +216,6 @@ func getSslKeys(inf *api.APIInfo, ctx context.Context) (tc.DeliveryServiceSSLKey

keyObjFromTv, ok, err := inf.Vault.GetDeliveryServiceSSLKeys(xmlID, version, inf.Tx.Tx, ctx)
if err != nil {
if err == sql.ErrNoRows {
return tc.DeliveryServiceSSLKeysV4{}, err
}
return tc.DeliveryServiceSSLKeysV4{}, errors.New("getting ssl keys: " + err.Error())
}
keyObj := tc.DeliveryServiceSSLKeysV4{}
Expand Down
4 changes: 1 addition & 3 deletions traffic_ops/traffic_ops_golang/deliveryservice/sslkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ func GeneratePlaceholderSelfSignedCert(ds tc.DeliveryServiceV5, inf *api.APIInfo
tv := inf.Vault
_, ok, err := tv.GetDeliveryServiceSSLKeys(ds.XMLID, "", tx, context)
if err != nil {
if err != sql.ErrNoRows {
return fmt.Errorf("getting latest ssl keys for XMLID '%s': %w", ds.XMLID, err), http.StatusInternalServerError
}
return fmt.Errorf("getting latest ssl keys for XMLID '%s': %w", ds.XMLID, err), http.StatusInternalServerError
}
if ok {
return nil, http.StatusOK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (p *Postgres) GetDeliveryServiceSSLKeys(xmlID string, version string, tx *s
err = tvTx.QueryRow(query, xmlID, version).Scan(&encryptedSslKeys)
if err != nil {
if err == sql.ErrNoRows {
return tc.DeliveryServiceSSLKeysV15{}, false, err
return tc.DeliveryServiceSSLKeysV15{}, false, nil
}
e := checkErrWithContext("Traffic Vault PostgreSQL: executing SELECT SSL Keys query", err, ctx.Err())
return tc.DeliveryServiceSSLKeysV15{}, false, e
Expand Down

0 comments on commit 7d5cebe

Please sign in to comment.