ocket8888 commented on a change in pull request #3534: TP Delivery Service Generate SSL update, new letsencrypt generate and… URL: https://github.com/apache/trafficcontrol/pull/3534#discussion_r334612564
########## File path: traffic_ops/traffic_ops_golang/deliveryservice/autorenewcerts.go ########## @@ -0,0 +1,200 @@ +package deliveryservice + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import ( + "context" + "database/sql" + "errors" + "github.com/apache/trafficcontrol/lib/go-log" + "github.com/apache/trafficcontrol/lib/go-tc" + "github.com/apache/trafficcontrol/lib/go-util" + "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api" + "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/config" + "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/riaksvc" + "net/http" + "strconv" + "strings" + "time" +) + +type DsKey struct { + XmlId string + Version sql.NullInt64 +} + +type DsExpirationInfo struct { + XmlId string + Version util.JSONIntStr + Expiration time.Time + AuthType string + Error error +} + +type ExpirationSummary struct { + LetsEncryptExpirations []DsExpirationInfo + SelfSignedExpirations []DsExpirationInfo + OtherExpirations []DsExpirationInfo +} + +func RenewCertificates(w http.ResponseWriter, r *http.Request) { + inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil) + if userErr != nil || sysErr != nil { + api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr) + return + } + defer inf.Close() + + if inf.Config.RiakEnabled == false { + api.HandleErr(w, r, inf.Tx.Tx, http.StatusServiceUnavailable, errors.New("the Riak service is unavailable"), errors.New("getting SSL keys from Riak by xml id: Riak is not configured")) Review comment: This hasn't been debated on the mailing list (so feel free to do so if you feel strongly about it) but general sentiment is that all server-side errors should return a simple 500 to avoid exposing information about weak points in the server to potential attackers. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services