Skip to content

Commit 32a24fa

Browse files
author
Rob Percival
committed
DefaultSignerFactory has been deleted
Key protobuf to crypto.Signer conversion is now handled by a global registry of handler funcs.
1 parent f31aacf commit 32a24fa

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

trillian/ctfe/ct_server/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/google/certificate-transparency-go/trillian/ctfe/configpb"
3333
"github.com/google/certificate-transparency-go/trillian/util"
3434
"github.com/google/trillian"
35-
"github.com/google/trillian/crypto/keys"
3635
"github.com/google/trillian/monitoring/prometheus"
3736
"github.com/prometheus/client_golang/prometheus/promhttp"
3837
"google.golang.org/grpc"
@@ -117,10 +116,8 @@ func main() {
117116
defer conn.Close()
118117
client := trillian.NewTrillianLogClient(conn)
119118

120-
sf := &keys.DefaultSignerFactory{}
121-
122119
for _, c := range cfg {
123-
handlers, err := ctfe.SetUpInstance(ctx, client, c, sf, *rpcDeadlineFlag, prometheus.MetricFactory{})
120+
handlers, err := ctfe.SetUpInstance(ctx, client, c, *rpcDeadlineFlag, prometheus.MetricFactory{})
124121
if err != nil {
125122
glog.Exitf("Failed to set up log instance for %+v: %v", cfg, err)
126123
}

trillian/ctfe/instance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var stringToKeyUsage = map[string]x509.ExtKeyUsage{
7777

7878
// SetUpInstance sets up a log instance that uses the specified client to communicate
7979
// with the Trillian RPC back end.
80-
func SetUpInstance(ctx context.Context, client trillian.TrillianLogClient, cfg *configpb.LogConfig, sf keys.SignerFactory, deadline time.Duration, mf monitoring.MetricFactory) (*PathHandlers, error) {
80+
func SetUpInstance(ctx context.Context, client trillian.TrillianLogClient, cfg *configpb.LogConfig, deadline time.Duration, mf monitoring.MetricFactory) (*PathHandlers, error) {
8181
// Check config validity.
8282
if len(cfg.RootsPemFile) == 0 {
8383
return nil, errors.New("need to specify RootsPemFile")
@@ -100,7 +100,7 @@ func SetUpInstance(ctx context.Context, client trillian.TrillianLogClient, cfg *
100100
return nil, fmt.Errorf("failed to unmarshal cfg.PrivateKey: %v", err)
101101
}
102102

103-
key, err := sf.NewSigner(ctx, keyProto.Message)
103+
key, err := keys.NewSigner(ctx, keyProto.Message)
104104
if err != nil {
105105
return nil, fmt.Errorf("failed to load private key: %v", err)
106106
}

trillian/ctfe/instance_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ import (
2020
"testing"
2121
"time"
2222

23+
// Register PEMKeyFile ProtoHandler
24+
_ "github.com/google/trillian/crypto/keys/pem/proto"
25+
2326
"github.com/golang/protobuf/ptypes"
2427
"github.com/golang/protobuf/ptypes/timestamp"
2528
ct "github.com/google/certificate-transparency-go"
2629
"github.com/google/certificate-transparency-go/trillian/ctfe/configpb"
27-
"github.com/google/trillian/crypto/keys"
2830
"github.com/google/trillian/crypto/keyspb"
2931
"github.com/google/trillian/monitoring"
3032
)
3133

3234
func TestSetUpInstance(t *testing.T) {
3335
ctx := context.Background()
34-
sf := &keys.DefaultSignerFactory{}
3536

3637
privKey, err := ptypes.MarshalAny(&keyspb.PEMKeyFile{Path: "../testdata/ct-http-server.privkey.pem", Password: "dirk"})
3738
if err != nil {
@@ -155,8 +156,7 @@ func TestSetUpInstance(t *testing.T) {
155156
}
156157

157158
for _, test := range tests {
158-
_, err := SetUpInstance(ctx, nil, &test.cfg, sf, time.Second, monitoring.InertMetricFactory{})
159-
if err != nil {
159+
if _, err := SetUpInstance(ctx, nil, &test.cfg, time.Second, monitoring.InertMetricFactory{}); err != nil {
160160
if test.errStr == "" {
161161
t.Errorf("(%v).SetUpInstance()=_,%v; want _,nil", test.desc, err)
162162
} else if !strings.Contains(err.Error(), test.errStr) {

trillian/integration/ct_integration_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import (
2424
"testing"
2525
"time"
2626

27+
// Register PEMKeyFile ProtoHandler
28+
_ "github.com/google/trillian/crypto/keys/pem/proto"
29+
2730
"github.com/golang/protobuf/ptypes"
2831
"github.com/google/certificate-transparency-go/trillian/ctfe"
2932
"github.com/google/certificate-transparency-go/trillian/ctfe/configpb"

trillian/integration/logenv.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/google/certificate-transparency-go/trillian/ctfe"
2727
"github.com/google/certificate-transparency-go/trillian/ctfe/configpb"
2828
"github.com/google/trillian"
29-
"github.com/google/trillian/crypto/keys"
3029
"github.com/google/trillian/monitoring/prometheus"
3130
"github.com/google/trillian/testonly/integration"
3231
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -72,9 +71,8 @@ func NewCTLogEnv(ctx context.Context, cfgs []*configpb.LogConfig, numSequencers
7271
go func(env *integration.LogEnv, server *http.Server, listener net.Listener, cfgs []*configpb.LogConfig) {
7372
defer wg.Done()
7473
client := trillian.NewTrillianLogClient(env.ClientConn)
75-
sf := &keys.DefaultSignerFactory{}
7674
for _, cfg := range cfgs {
77-
handlers, err := ctfe.SetUpInstance(ctx, client, cfg, sf, 10*time.Second, prometheus.MetricFactory{})
75+
handlers, err := ctfe.SetUpInstance(ctx, client, cfg, 10*time.Second, prometheus.MetricFactory{})
7876
if err != nil {
7977
glog.Fatalf("Failed to set up log instance for %+v: %v", cfg, err)
8078
}

0 commit comments

Comments
 (0)