WIP on issue #202: OCSP Responder work

This commit is contained in:
J.C. Jones 2015-05-27 23:32:34 -07:00
parent 9167fb067f
commit 1008bd824d
5 changed files with 30 additions and 11 deletions

View File

@ -113,6 +113,7 @@ func main() {
auditlogger.Info(app.VersionString())
// Add HandlerTimer to output resp time + success/failure stats to statsd
auditlogger.Info(fmt.Sprintf("Server running, listening on %s...\n", c.WFE.ListenAddress))
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
cmd.FailOnError(err, "Error starting HTTP server")
}

View File

@ -14,6 +14,10 @@ import (
"net/http"
"time"
// Load both drivers to allow configuring either
_ "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/go-sql-driver/mysql"
_ "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/mattn/go-sqlite3"
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
cfocsp "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cloudflare/cfssl/ocsp"
"golang.org/x/crypto/ocsp"
@ -98,7 +102,7 @@ func (src *DBSource) Response(req *ocsp.Request) (response []byte, present bool)
}
func main() {
app := cmd.NewAppShell("boulder-ocsp")
app := cmd.NewAppShell("boulder-ocsp-responder")
app.Action = func(c cmd.Config) {
// Set up logging
stats, err := statsd.NewClient(c.Statsd.Server, c.Statsd.Prefix)
@ -115,7 +119,7 @@ func main() {
go cmd.ProfileCmd("OCSP", stats)
// Connect to the DB
db, err := sql.Open(c.OCSP.DBDriver, c.OCSP.DBName)
db, err := sql.Open(c.OCSPResponder.DBDriver, c.OCSPResponder.DBName)
cmd.FailOnError(err, "Could not connect to database")
defer db.Close()
@ -133,12 +137,13 @@ func main() {
cmd.FailOnError(err, "Could not connect to OCSP database")
// Configure HTTP
http.Handle(c.OCSP.Path, cfocsp.Responder{Source: src})
http.Handle(c.OCSPResponder.Path, cfocsp.Responder{Source: src})
auditlogger.Info(app.VersionString())
// Add HandlerTimer to output resp time + success/failure stats to statsd
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
auditlogger.Info(fmt.Sprintf("Server running, listening on %s...\n", c.OCSPResponder.ListenAddress))
err = http.ListenAndServe(c.OCSPResponder.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
cmd.FailOnError(err, "Error starting HTTP server")
}

View File

@ -149,7 +149,7 @@ func main() {
})
app.Config = func(c *cli.Context, config cmd.Config) cmd.Config {
config.OCSP.ResponseLimit = c.GlobalInt("limit")
config.OCSPUpdater.ResponseLimit = c.GlobalInt("limit")
return config
}
@ -167,7 +167,7 @@ func main() {
blog.SetAuditLogger(auditlogger)
// Configure DB
dbMap, err := sa.NewDbMap(c.OCSP.DBDriver, c.OCSP.DBName)
dbMap, err := sa.NewDbMap(c.OCSPUpdater.DBDriver, c.OCSPUpdater.DBName)
cmd.FailOnError(err, "Could not connect to database")
cac, closeChan := setupClients(c)
@ -185,13 +185,13 @@ func main() {
auditlogger.Info(app.VersionString())
// Calculate the cut-off timestamp
dur, err := time.ParseDuration(c.OCSP.MinTimeToExpiry)
dur, err := time.ParseDuration(c.OCSPUpdater.MinTimeToExpiry)
cmd.FailOnError(err, "Could not parse MinTimeToExpiry from config.")
oldestLastUpdatedTime := time.Now().Add(-dur)
auditlogger.Info(fmt.Sprintf("Searching for OCSP reponses older than %s", oldestLastUpdatedTime))
count := int(math.Min(float64(ocspResponseLimit), float64(c.OCSP.ResponseLimit)))
count := int(math.Min(float64(ocspResponseLimit), float64(c.OCSPUpdater.ResponseLimit)))
err = findStaleResponses(cac, dbMap, oldestLastUpdatedTime, count)
if err != nil {

View File

@ -99,10 +99,16 @@ type Config struct {
Password string
}
OCSP struct {
OCSPResponder struct {
DBDriver string
DBName string
Path string
ListenAddress string
}
OCSPUpdater struct {
DBDriver string
DBName string
Path string
MinTimeToExpiry string
ResponseLimit int
}

View File

@ -64,7 +64,14 @@
"dbName": ":memory:"
},
"ocsp": {
"ocspResponder": {
"dbDriver": "sqlite3",
"dbName": ":memory:",
"path": "http://localhost:4001",
"listenAddress": "localhost:4001"
},
"ocspUpdater": {
"dbDriver": "sqlite3",
"dbName": ":memory:",
"minTimeToExpiry": "72h"