WIP on issue #202: OCSP Responder work
This commit is contained in:
parent
9167fb067f
commit
1008bd824d
|
|
@ -113,6 +113,7 @@ func main() {
|
||||||
auditlogger.Info(app.VersionString())
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
// Add HandlerTimer to output resp time + success/failure stats to statsd
|
// 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))
|
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
|
||||||
cmd.FailOnError(err, "Error starting HTTP server")
|
cmd.FailOnError(err, "Error starting HTTP server")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"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"
|
"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"
|
cfocsp "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cloudflare/cfssl/ocsp"
|
||||||
"golang.org/x/crypto/ocsp"
|
"golang.org/x/crypto/ocsp"
|
||||||
|
|
@ -98,7 +102,7 @@ func (src *DBSource) Response(req *ocsp.Request) (response []byte, present bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cmd.NewAppShell("boulder-ocsp")
|
app := cmd.NewAppShell("boulder-ocsp-responder")
|
||||||
app.Action = func(c cmd.Config) {
|
app.Action = func(c cmd.Config) {
|
||||||
// Set up logging
|
// Set up logging
|
||||||
stats, err := statsd.NewClient(c.Statsd.Server, c.Statsd.Prefix)
|
stats, err := statsd.NewClient(c.Statsd.Server, c.Statsd.Prefix)
|
||||||
|
|
@ -115,7 +119,7 @@ func main() {
|
||||||
go cmd.ProfileCmd("OCSP", stats)
|
go cmd.ProfileCmd("OCSP", stats)
|
||||||
|
|
||||||
// Connect to the DB
|
// 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")
|
cmd.FailOnError(err, "Could not connect to database")
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
|
@ -133,12 +137,13 @@ func main() {
|
||||||
cmd.FailOnError(err, "Could not connect to OCSP database")
|
cmd.FailOnError(err, "Could not connect to OCSP database")
|
||||||
|
|
||||||
// Configure HTTP
|
// Configure HTTP
|
||||||
http.Handle(c.OCSP.Path, cfocsp.Responder{Source: src})
|
http.Handle(c.OCSPResponder.Path, cfocsp.Responder{Source: src})
|
||||||
|
|
||||||
auditlogger.Info(app.VersionString())
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
// Add HandlerTimer to output resp time + success/failure stats to statsd
|
// 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")
|
cmd.FailOnError(err, "Error starting HTTP server")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ func main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Config = func(c *cli.Context, config cmd.Config) cmd.Config {
|
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
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ func main() {
|
||||||
blog.SetAuditLogger(auditlogger)
|
blog.SetAuditLogger(auditlogger)
|
||||||
|
|
||||||
// Configure DB
|
// 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")
|
cmd.FailOnError(err, "Could not connect to database")
|
||||||
|
|
||||||
cac, closeChan := setupClients(c)
|
cac, closeChan := setupClients(c)
|
||||||
|
|
@ -185,13 +185,13 @@ func main() {
|
||||||
auditlogger.Info(app.VersionString())
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
// Calculate the cut-off timestamp
|
// 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.")
|
cmd.FailOnError(err, "Could not parse MinTimeToExpiry from config.")
|
||||||
|
|
||||||
oldestLastUpdatedTime := time.Now().Add(-dur)
|
oldestLastUpdatedTime := time.Now().Add(-dur)
|
||||||
auditlogger.Info(fmt.Sprintf("Searching for OCSP reponses older than %s", oldestLastUpdatedTime))
|
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)
|
err = findStaleResponses(cac, dbMap, oldestLastUpdatedTime, count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,16 @@ type Config struct {
|
||||||
Password string
|
Password string
|
||||||
}
|
}
|
||||||
|
|
||||||
OCSP struct {
|
OCSPResponder struct {
|
||||||
DBDriver string
|
DBDriver string
|
||||||
DBName string
|
DBName string
|
||||||
Path string
|
Path string
|
||||||
|
ListenAddress string
|
||||||
|
}
|
||||||
|
|
||||||
|
OCSPUpdater struct {
|
||||||
|
DBDriver string
|
||||||
|
DBName string
|
||||||
MinTimeToExpiry string
|
MinTimeToExpiry string
|
||||||
ResponseLimit int
|
ResponseLimit int
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,14 @@
|
||||||
"dbName": ":memory:"
|
"dbName": ":memory:"
|
||||||
},
|
},
|
||||||
|
|
||||||
"ocsp": {
|
"ocspResponder": {
|
||||||
|
"dbDriver": "sqlite3",
|
||||||
|
"dbName": ":memory:",
|
||||||
|
"path": "http://localhost:4001",
|
||||||
|
"listenAddress": "localhost:4001"
|
||||||
|
},
|
||||||
|
|
||||||
|
"ocspUpdater": {
|
||||||
"dbDriver": "sqlite3",
|
"dbDriver": "sqlite3",
|
||||||
"dbName": ":memory:",
|
"dbName": ":memory:",
|
||||||
"minTimeToExpiry": "72h"
|
"minTimeToExpiry": "72h"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue