Skip to content

Commit 6e13e75

Browse files
committed
add boulder-mtca
1 parent c3c9094 commit 6e13e75

13 files changed

Lines changed: 587 additions & 2 deletions

File tree

cmd/boulder-mtca/main.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package notmain
2+
3+
import (
4+
"context"
5+
"flag"
6+
"os"
7+
8+
"github.com/jmhodges/clock"
9+
10+
"github.com/letsencrypt/boulder/cmd"
11+
bgrpc "github.com/letsencrypt/boulder/grpc"
12+
"github.com/letsencrypt/boulder/issuance"
13+
mtca "github.com/letsencrypt/boulder/mtca"
14+
mtcapb "github.com/letsencrypt/boulder/mtca/proto"
15+
)
16+
17+
type Config struct {
18+
MTCA struct {
19+
cmd.ServiceConfig
20+
21+
GRPCMTCA *cmd.GRPCServerConfig
22+
23+
// Issuer holds the configuration for a single MTCA instance with a single mtcaID.
24+
// We run a separate process for each issuer.
25+
// TODO: the issuance package parses the CA certificate as a self-signed X.509
26+
// certificate, but per MTC draft, a CA SHOULD be represented by an RFC 9925
27+
// unsigned certificate: https://www.rfc-editor.org/rfc/rfc9925.html.
28+
Issuer issuance.IssuerConfig
29+
}
30+
31+
Syslog cmd.SyslogConfig
32+
OpenTelemetry cmd.OpenTelemetryConfig
33+
}
34+
35+
func main() {
36+
grpcAddr := flag.String("addr", "", "gRPC listen address override")
37+
debugAddr := flag.String("debug-addr", "", "Debug server address override")
38+
configFile := flag.String("config", "", "File path to the configuration file for this service")
39+
flag.Parse()
40+
if *configFile == "" {
41+
flag.Usage()
42+
os.Exit(1)
43+
}
44+
45+
var c Config
46+
err := cmd.ReadConfigFile(*configFile, &c)
47+
cmd.FailOnError(err, "Reading JSON config file into config structure")
48+
49+
if *grpcAddr != "" {
50+
c.MTCA.GRPCMTCA.Address = *grpcAddr
51+
}
52+
if *debugAddr != "" {
53+
c.MTCA.DebugAddr = *debugAddr
54+
}
55+
56+
scope, logger, oTelShutdown := cmd.StatsAndLogging(c.Syslog, c.OpenTelemetry, c.MTCA.DebugAddr)
57+
defer oTelShutdown(context.Background())
58+
cmd.LogStartup(logger)
59+
60+
tlsConfig, err := c.MTCA.TLS.Load(scope)
61+
cmd.FailOnError(err, "Loading TLS config")
62+
63+
clk := clock.New()
64+
65+
issuer, err := issuance.LoadIssuer(c.MTCA.Issuer, clk)
66+
cmd.FailOnError(err, "Loading issuer")
67+
68+
mtcaImpl := mtca.New(issuer)
69+
70+
srv := bgrpc.NewServer(c.MTCA.GRPCMTCA, logger).Add(
71+
&mtcapb.MTCA_ServiceDesc, mtcaImpl)
72+
73+
start, err := srv.Build(tlsConfig, scope, clk)
74+
cmd.FailOnError(err, "Unable to setup MTCA gRPC server")
75+
76+
cmd.FailOnError(start(), "MTCA gRPC service failed")
77+
}
78+
79+
func init() {
80+
cmd.RegisterCommand("boulder-mtca", main, &cmd.ConfigValidator{Config: &Config{}})
81+
}

cmd/boulder/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
_ "github.com/letsencrypt/boulder/cmd/bad-key-revoker"
99
_ "github.com/letsencrypt/boulder/cmd/boulder-ca"
10+
_ "github.com/letsencrypt/boulder/cmd/boulder-mtca"
1011
_ "github.com/letsencrypt/boulder/cmd/boulder-observer"
1112
_ "github.com/letsencrypt/boulder/cmd/boulder-publisher"
1213
_ "github.com/letsencrypt/boulder/cmd/boulder-ra"

cmd/boulder/main_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func TestConfigValidation(t *testing.T) {
3131
switch cmdName {
3232
case "boulder-ca":
3333
fileNames = []string{"ca.json"}
34+
case "boulder-mtca":
35+
fileNames = []string{"mtca.json"}
3436
case "boulder-observer":
3537
fileNames = []string{"observer.yml"}
3638
case "boulder-publisher":

mtca/mtca.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package mtca
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/letsencrypt/boulder/issuance"
8+
mtcapb "github.com/letsencrypt/boulder/mtca/proto"
9+
)
10+
11+
var _ mtcapb.MTCAServer = &mtca{}
12+
13+
func New(issuer *issuance.Issuer) *mtca {
14+
return &mtca{
15+
issuer: issuer,
16+
}
17+
}
18+
19+
type mtca struct {
20+
mtcapb.UnimplementedMTCAServer
21+
issuer *issuance.Issuer
22+
}
23+
24+
func (m *mtca) Issue(ctx context.Context, req *mtcapb.IssueRequest) (*mtcapb.IssueResponse, error) {
25+
return nil, fmt.Errorf("not implemented")
26+
}

mtca/proto/mtca.pb.go

Lines changed: 224 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mtca/proto/mtca.proto

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
syntax = "proto3";
2+
3+
package mtca;
4+
option go_package = "github.com/letsencrypt/boulder/mtca/proto";
5+
6+
// MTCA issues MTC certificates.
7+
service MTCA {
8+
// Submit requests that the CA start the process of creating a standalone certificate
9+
// for the given request. It returns once a checkpoint has been signed that includes
10+
// that certificate's TBSCertificateLogEntry, but does not wait for cosignatures.
11+
rpc Issue(IssueRequest) returns (IssueResponse) {}
12+
}
13+
14+
message IssueRequest {
15+
// Next unused field number: 4
16+
bytes csr = 1;
17+
int64 registrationID = 2;
18+
int64 orderID = 3;
19+
}
20+
21+
message IssueResponse {
22+
// Next unused field number: 4
23+
string mtcLogID = 1;
24+
int64 mtcSerialNumber = 2;
25+
int64 checkpointSubtreeID = 3;
26+
}

0 commit comments

Comments
 (0)