Skip to content

Commit 1bb9444

Browse files
committed
Revert "Support GCP Secret Manager for signer key pair (transparency-dev#40)"
This reverts commit 9d5daa4.
1 parent 2c64000 commit 1bb9444

File tree

9 files changed

+30
-293
lines changed

9 files changed

+30
-293
lines changed

cmd/gcp/main.go

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"syscall"
2828
"time"
2929

30+
"github.com/google/trillian/crypto/keys/pem"
3031
"github.com/google/trillian/monitoring/opencensus"
3132
"github.com/google/trillian/monitoring/prometheus"
3233
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -49,25 +50,25 @@ var (
4950
notAfterStart timestampFlag
5051
notAfterLimit timestampFlag
5152

52-
httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).")
53-
metricsEndpoint = flag.String("metrics_endpoint", "", "Endpoint for serving metrics; if left empty, metrics will be visible on --http_endpoint.")
54-
tesseraDeadline = flag.Duration("tessera_deadline", time.Second*10, "Deadline for Tessera requests.")
55-
maskInternalErrors = flag.Bool("mask_internal_errors", false, "Don't return error strings with Internal Server Error HTTP responses.")
56-
tracing = flag.Bool("tracing", false, "If true opencensus Stackdriver tracing will be enabled. See https://opencensus.io/.")
57-
tracingProjectID = flag.String("tracing_project_id", "", "project ID to pass to stackdriver. Can be empty for GCP, consult docs for other platforms.")
58-
tracingPercent = flag.Int("tracing_percent", 0, "Percent of requests to be traced. Zero is a special case to use the DefaultSampler.")
59-
origin = flag.String("origin", "", "Origin of the log, for checkpoints and the monitoring prefix.")
60-
projectID = flag.String("project_id", "", "GCP ProjectID.")
61-
bucket = flag.String("bucket", "", "Name of the bucket to store the log in.")
62-
spannerDB = flag.String("spanner_db_path", "", "Spanner database path: projects/{projectId}/instances/{instanceId}/databases/{databaseId}.")
63-
spannerDedupDB = flag.String("spanner_dedup_db_path", "", "Spanner deduplication database path: projects/{projectId}/instances/{instanceId}/databases/{databaseId}.")
64-
rootsPemFile = flag.String("roots_pem_file", "", "Path to the file containing root certificates that are acceptable to the log. The certs are served through get-roots endpoint.")
65-
rejectExpired = flag.Bool("reject_expired", false, "If true then the certificate validity period will be checked against the current time during the validation of submissions. This will cause expired certificates to be rejected.")
66-
rejectUnexpired = flag.Bool("reject_unexpired", false, "If true then CTFE rejects certificates that are either currently valid or not yet valid.")
67-
extKeyUsages = flag.String("ext_key_usages", "", "If set, will restrict the set of such usages that the server will accept. By default all are accepted. The values specified must be ones known to the x509 package.")
68-
rejectExtensions = flag.String("reject_extension", "", "A list of X.509 extension OIDs, in dotted string form (e.g. '2.3.4.5') which, if present, should cause submissions to be rejected.")
69-
signerPublicKeySecretName = flag.String("signer_public_key_secret_name", "", "Public key secret name for checkpoints and SCTs signer. Format: projects/{projectId}/secrets/{secretName}/versions/{secretVersion}.")
70-
signerPrivateKeySecretName = flag.String("signer_private_key_secret_name", "", "Private key secret name for checkpoints and SCTs signer. Format: projects/{projectId}/secrets/{secretName}/versions/{secretVersion}.")
53+
httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).")
54+
metricsEndpoint = flag.String("metrics_endpoint", "", "Endpoint for serving metrics; if left empty, metrics will be visible on --http_endpoint.")
55+
tesseraDeadline = flag.Duration("tessera_deadline", time.Second*10, "Deadline for Tessera requests.")
56+
maskInternalErrors = flag.Bool("mask_internal_errors", false, "Don't return error strings with Internal Server Error HTTP responses.")
57+
tracing = flag.Bool("tracing", false, "If true opencensus Stackdriver tracing will be enabled. See https://opencensus.io/.")
58+
tracingProjectID = flag.String("tracing_project_id", "", "project ID to pass to stackdriver. Can be empty for GCP, consult docs for other platforms.")
59+
tracingPercent = flag.Int("tracing_percent", 0, "Percent of requests to be traced. Zero is a special case to use the DefaultSampler.")
60+
origin = flag.String("origin", "", "Origin of the log, for checkpoints and the monitoring prefix.")
61+
projectID = flag.String("project_id", "", "GCP ProjectID.")
62+
bucket = flag.String("bucket", "", "Name of the bucket to store the log in.")
63+
spannerDB = flag.String("spanner_db_path", "", "Spanner database path: projects/{projectId}/instances/{instanceId}/databases/{databaseId}.")
64+
spannerDedupDB = flag.String("spanner_dedup_db_path", "", "Spanner deduplication database path: projects/{projectId}/instances/{instanceId}/databases/{databaseId}.")
65+
rootsPemFile = flag.String("roots_pem_file", "", "Path to the file containing root certificates that are acceptable to the log. The certs are served through get-roots endpoint.")
66+
rejectExpired = flag.Bool("reject_expired", false, "If true then the certificate validity period will be checked against the current time during the validation of submissions. This will cause expired certificates to be rejected.")
67+
rejectUnexpired = flag.Bool("reject_unexpired", false, "If true then CTFE rejects certificates that are either currently valid or not yet valid.")
68+
extKeyUsages = flag.String("ext_key_usages", "", "If set, will restrict the set of such usages that the server will accept. By default all are accepted. The values specified must be ones known to the x509 package.")
69+
rejectExtensions = flag.String("reject_extension", "", "A list of X.509 extension OIDs, in dotted string form (e.g. '2.3.4.5') which, if present, should cause submissions to be rejected.")
70+
privKey = flag.String("private_key", "", "Path to a private key .der file. Used to sign checkpoints and SCTs.")
71+
privKeyPass = flag.String("password", "", "private_key password.")
7172
)
7273

7374
// nolint:staticcheck
@@ -76,9 +77,10 @@ func main() {
7677
flag.Parse()
7778
ctx := context.Background()
7879

79-
signer, err := NewSecretManagerSigner(ctx, *signerPublicKeySecretName, *signerPrivateKeySecretName)
80+
// TODO(phboneff): move to something else, like KMS
81+
signer, err := pem.ReadPrivateKeyFile(*privKey, *privKeyPass)
8082
if err != nil {
81-
klog.Exitf("Can't create secret manager signer: %v", err)
83+
klog.Exitf("Can't open key: %v", err)
8284
}
8385

8486
vCfg, err := sctfe.ValidateLogConfig(*origin, *projectID, *bucket, *spannerDB, *rootsPemFile, *rejectExpired, *rejectUnexpired, *extKeyUsages, *rejectExtensions, notAfterStart.t, notAfterLimit.t, signer)

cmd/gcp/secret_manager.go

Lines changed: 0 additions & 143 deletions
This file was deleted.

config.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package sctfe
1616

1717
import (
1818
"crypto"
19-
"crypto/ecdsa"
2019
"errors"
2120
"fmt"
2221
"strings"
@@ -33,6 +32,7 @@ type ValidatedLogConfig struct {
3332
// is also its submission prefix, as per https://c2sp.org/static-ct-api.
3433
Origin string
3534
// Used to sign the checkpoint and SCTs.
35+
// TODO(phboneff): check that this is RSA or ECDSA only.
3636
Signer crypto.Signer
3737
// If set, ExtKeyUsages will restrict the set of such usages that the
3838
// server will accept. By default all are accepted. The values specified
@@ -90,16 +90,6 @@ func ValidateLogConfig(origin string, projectID string, bucket string, spannerDB
9090
return nil, errors.New("empty rootsPemFile")
9191
}
9292

93-
// Validate signer that only ECDSA is supported.
94-
if signer == nil {
95-
return nil, errors.New("empty signer")
96-
}
97-
switch keyType := signer.Public().(type) {
98-
case *ecdsa.PublicKey:
99-
default:
100-
return nil, fmt.Errorf("unsupported key type: %v", keyType)
101-
}
102-
10393
lExtKeyUsages := []string{}
10494
lRejectExtensions := []string{}
10595
if extKeyUsages != "" {

deployment/live/gcp/test/.terraform.lock.hcl

Lines changed: 0 additions & 41 deletions
This file was deleted.

deployment/live/gcp/test/README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ Terraforming the project can be done by:
3838
1. `cd` to the relevant directory for the environment to deploy/change (e.g. `ci`)
3939
2. Run `terragrunt apply`
4040

41-
Store the Secret Manager resource ID of signer key pair into the environment variables:
42-
43-
```sh
44-
export SCTFE_SIGNER_ECDSA_P256_PUBLIC_KEY_ID=$(terragrunt output -raw ecdsa_p256_public_key_id)
45-
export SCTFE_SIGNER_ECDSA_P256_PRIVATE_KEY_ID=$(terragrunt output -raw ecdsa_p256_private_key_id)
46-
```
47-
4841
## Run the SCTFE
4942

5043
### With fake chains
@@ -57,10 +50,10 @@ go run ./cmd/gcp/ \
5750
--bucket=${GOOGLE_PROJECT}-${TESSERA_BASE_NAME}-bucket \
5851
--spanner_db_path=projects/${GOOGLE_PROJECT}/instances/${TESSERA_BASE_NAME}/databases/${TESSERA_BASE_NAME}-db \
5952
--spanner_dedup_db_path=projects/${GOOGLE_PROJECT}/instances/${TESSERA_BASE_NAME}/databases/${TESSERA_BASE_NAME}-dedup-db \
53+
--private_key=./testdata/ct-http-server.privkey.pem \
54+
--password=dirk \
6055
--roots_pem_file=./testdata/fake-ca.cert \
61-
--origin=${TESSERA_BASE_NAME} \
62-
--signer_public_key_secret_name=${SCTFE_SIGNER_ECDSA_P256_PUBLIC_KEY_ID} \
63-
--signer_private_key_secret_name=${SCTFE_SIGNER_ECDSA_P256_PRIVATE_KEY_ID}
56+
--origin=${TESSERA_BASE_NAME}
6457
```
6558

6659
In a different terminal you can either mint and submit certificates manually, or
@@ -138,6 +131,7 @@ go run ./client/ctclient get-roots --log_uri=${SRC_LOG_URI} --text=false > /tmp/
138131
sed -i 's-""-"/tmp/hammercfg/roots.pem"-g' /tmp/hammercfg/hammer.cfg
139132
```
140133

134+
141135
Run the SCTFE with the same roots:
142136

143137
```bash
@@ -146,11 +140,11 @@ go run ./cmd/gcp/ \
146140
--project_id=${GOOGLE_PROJECT} \
147141
--bucket=${GOOGLE_PROJECT}-${TESSERA_BASE_NAME}-bucket \
148142
--spanner_db_path=projects/${GOOGLE_PROJECT}/instances/${TESSERA_BASE_NAME}/databases/${TESSERA_BASE_NAME}-db \
143+
--private_key=./testdata/ct-http-server.privkey.pem \
144+
--password=dirk \
149145
--roots_pem_file=/tmp/hammercfg/roots.pem \
150146
--origin=${TESSERA_BASE_NAME} \
151147
--spanner_dedup_db_path=projects/${GOOGLE_PROJECT}/instances/${TESSERA_BASE_NAME}/databases/${TESSERA_BASE_NAME}-dedup-db \
152-
--signer_public_key_secret_name=${SCTFE_SIGNER_ECDSA_P256_PUBLIC_KEY_ID} \
153-
--signer_private_key_secret_name=${SCTFE_SIGNER_ECDSA_P256_PRIVATE_KEY_ID} \
154148
-v=3
155149
```
156150

deployment/modules/gcp/storage/main.tf

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -65,55 +65,3 @@ resource "google_spanner_database" "dedup_db" {
6565
"CREATE TABLE IDSeq (id INT64 NOT NULL, h BYTES(MAX) NOT NULL, idx INT64 NOT NULL,) PRIMARY KEY (id, h)",
6666
]
6767
}
68-
69-
# Secret Manager
70-
71-
# ECDSA key with P256 elliptic curve. Do NOT use this in production environment.
72-
#
73-
# Security Notice
74-
# The private key generated by this resource will be stored unencrypted in your
75-
# Terraform state file. Use of this resource for production deployments is not
76-
# recommended. Instead, generate a private key file outside of Terraform and
77-
# distribute it securely to the system where Terraform will be run.
78-
#
79-
# See https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key.
80-
resource "tls_private_key" "sctfe_ecdsa_p256" {
81-
algorithm = "ECDSA"
82-
ecdsa_curve = "P256"
83-
}
84-
85-
resource "google_secret_manager_secret" "sctfe_ecdsa_p256_public_key" {
86-
secret_id = "sctfe-ecdsa-p256-public-key"
87-
88-
labels = {
89-
label = "sctfe-public-key"
90-
}
91-
92-
replication {
93-
auto {}
94-
}
95-
}
96-
97-
resource "google_secret_manager_secret_version" "sctfe_ecdsa_p256_public_key" {
98-
secret = google_secret_manager_secret.sctfe_ecdsa_p256_public_key.id
99-
100-
secret_data = tls_private_key.sctfe_ecdsa_p256.public_key_pem
101-
}
102-
103-
resource "google_secret_manager_secret" "sctfe_ecdsa_p256_private_key" {
104-
secret_id = "sctfe-ecdsa-p256-private-key"
105-
106-
labels = {
107-
label = "sctfe-private-key"
108-
}
109-
110-
replication {
111-
auto {}
112-
}
113-
}
114-
115-
resource "google_secret_manager_secret_version" "sctfe_ecdsa_p256_private_key" {
116-
secret = google_secret_manager_secret.sctfe_ecdsa_p256_private_key.id
117-
118-
secret_data = tls_private_key.sctfe_ecdsa_p256.private_key_pem
119-
}

0 commit comments

Comments
 (0)