diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-27 15:16:24 +0100 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-27 15:16:24 +0100 |
commit | dd19521190f39a8b1704adb724f5f812040f91e4 (patch) | |
tree | ec39c578f5272d708276956b4bcd251d2e9ea0b0 /server | |
parent | d90eed44990f34a87c286ee21f5579506143040d (diff) |
decoupled log instance and info
Makes things a bit more modular. As part of this process I also
replaced ct/x509 with crypto/x509, which already suits our needs.
Diffstat (limited to 'server')
-rw-r--r-- | server/main.go | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/server/main.go b/server/main.go index 618d40b..84d92ea 100644 --- a/server/main.go +++ b/server/main.go @@ -1,4 +1,4 @@ -// Package main provides an STFE binary +// Package main provides an STFE server binary package main import ( @@ -11,19 +11,15 @@ import ( "github.com/google/trillian" "github.com/system-transparency/stfe" "google.golang.org/grpc" - - "github.com/google/certificate-transparency-go/trillian/ctfe" - ctutil "github.com/google/certificate-transparency-go/trillian/util" - "github.com/google/certificate-transparency-go/x509" ) var ( - httpEndpoint = flag.String("http_endpoint", "localhost:6965", "host:port specification of where stfe serves clients") - rpcBackend = flag.String("log_rpc_server", "localhost:6962", "host:port specification of where Trillian serves clients") - prefix = flag.String("prefix", "/st/v1", "a prefix that proceeds each endpoint path") - trillianID = flag.Int64("trillian_id", 5991359069696313945, "log identifier in the Trillian database") - rpcDeadline = flag.Duration("rpc_deadline", time.Second*10, "deadline for backend RPC requests") - anchorsPemFile = flag.String("anchors_file", "testdata/chain/rgdd-root.pem", "path to a file containing PEM-encoded X.509 root certificates") + httpEndpoint = flag.String("http_endpoint", "localhost:6965", "host:port specification of where stfe serves clients") + rpcBackend = flag.String("log_rpc_server", "localhost:6962", "host:port specification of where Trillian serves clients") + prefix = flag.String("prefix", "/st/v1", "a prefix that proceeds each endpoint path") + trillianID = flag.Int64("trillian_id", 5991359069696313945, "log identifier in the Trillian database") + rpcDeadline = flag.Duration("rpc_deadline", time.Second*10, "deadline for backend RPC requests") + anchorPath = flag.String("anchor_path", "testdata/chain/rgdd-root.pem", "path to a file containing PEM-encoded X.509 root certificates") ) func main() { @@ -35,21 +31,22 @@ func main() { if err != nil { glog.Fatal(err) } + client := trillian.NewTrillianLogClient(conn) glog.Info("Creating HTTP request multiplexer") mux := http.NewServeMux() http.Handle("/", mux) - // TODO: proper setup - glog.Info("Loading trust anchors") - cert_pool := ctfe.NewPEMCertPool() - cert_pool.AppendCertsFromPEMFile(*anchorsPemFile) - anchors := ctfe.NewCertValidationOpts(cert_pool, time.Now(), true, false, nil, nil, false, []x509.ExtKeyUsage{}) - glog.Infof("%v", cert_pool.Subjects()) + lp, err := stfe.NewLogParameters([]byte("rgdd"), *trillianID, *prefix, *anchorPath) + if err != nil { + glog.Fatalf("failed setting up log parameters: %v", err) + } - glog.Info("Creating STFE server instance") - stfe_server := stfe.NewInstance(*prefix, *trillianID, trillian.NewTrillianLogClient(conn), *rpcDeadline, new(ctutil.SystemTimeSource), anchors, *cert_pool) - stfe_server.AddEndpoints(mux) + i, err := stfe.NewInstance(lp, client, *rpcDeadline, mux) + if err != nil { + glog.Fatalf("failed setting up log instance: %v", err) + } + glog.Infof("Configured: %s", i) glog.Infof("Serving on %v%v", *httpEndpoint, *prefix) srv := http.Server{Addr: *httpEndpoint} |