diff options
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} | 
