Skip to content

Commit edb6df6

Browse files
committed
Replace ct_server with TesseraCT in setup
In the setup scaffolding workflow, update Fulcio to use the Static CT log TesseraCT instead of the Trillian-based ct_server. The createtree job is obsolete, so it is removed. TesseraCT does not use a config file, all parameters are passed in via command line, so remove the CT config map and the config field from the secret. TesseraCT does not support encrypting the private key, so remove support for supplying a password. Signed-off-by: Colleen Murphy <[email protected]>
1 parent 8e9b439 commit edb6df6

File tree

18 files changed

+131
-569
lines changed

18 files changed

+131
-569
lines changed

.github/workflows/add-remove-new-fulcio.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,14 @@ jobs:
197197
198198
- name: Dump the trusted certs
199199
run: |
200-
curl ${CTLOG_URL}/sigstorescaffolding/ct/v1/get-roots | jq .certificates
200+
curl ${CTLOG_URL}/ct/v1/get-roots | jq .certificates
201201
env:
202202
CTLOG_URL: ${{ env.CTLOG_URL }}
203203

204204
- name: Verify both Fulcio certs are there
205205
run: |
206206
go run ./cmd/ctlog/verifyfulcio/main.go \
207207
--ctlog-url ${CTLOG_URL} \
208-
--log-prefix sigstorescaffolding \
209208
--fulcio ${FULCIO_URL} \
210209
--fulcio ${NEW_FULCIO_URL}
211210
env:
@@ -226,15 +225,14 @@ jobs:
226225
227226
- name: Dump the trusted certs
228227
run: |
229-
curl ${CTLOG_URL}/sigstorescaffolding/ct/v1/get-roots | jq .certificates
228+
curl ${CTLOG_URL}/ct/v1/get-roots | jq .certificates
230229
env:
231230
CTLOG_URL: ${{ env.CTLOG_URL }}
232231

233232
- name: Verify that only new Fulcio cert is there
234233
run: |
235234
go run ./cmd/ctlog/verifyfulcio/main.go \
236235
--ctlog-url ${CTLOG_URL} \
237-
--log-prefix sigstorescaffolding \
238236
--fulcio ${NEW_FULCIO_URL}
239237
env:
240238
CTLOG_URL: ${{ env.CTLOG_URL }}

cmd/ctlog/createctconfig/main.go

Lines changed: 29 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ import (
2424
"errors"
2525
"flag"
2626
"fmt"
27-
"log"
2827
"net/url"
2928
"os"
30-
"strconv"
3129

3230
fulcioclient "github.com/sigstore/fulcio/pkg/api"
3331
"github.com/sigstore/scaffolding/pkg/ctlog"
@@ -44,26 +42,18 @@ import (
4442
)
4543

4644
const (
47-
// Key in the configmap holding the value of the tree.
48-
treeKey = "treeID"
49-
configKey = "config"
5045
privateKey = "private"
5146
publicKey = "public"
5247
bitSize = 4096
5348
)
5449

5550
var (
56-
cmname = flag.String("configmap", "ctlog-config", "Name of the configmap where the treeID lives")
57-
privateKeySecret = flag.String("private-secret", "", "If there's an existing private key that should be used, read it from this secret, decrypt with the key-password and use it instead of creating a new one.")
58-
secretName = flag.String("secret", "ctlog-secrets", "Name of the secret to create for the keyfiles")
59-
pubKeySecretName = flag.String("pubkeysecret", "ctlog-public-key", "Name of the secret to create containing only the public key")
60-
ctlogPrefix = flag.String("log-prefix", "sigstorescaffolding", "Prefix to append to the url. This is basically the name of the log.")
61-
fulcioURL = flag.String("fulcio-url", "http://fulcio.fulcio-system.svc", "Where to fetch the fulcio Root CA from")
62-
trillianServerAddr = flag.String("trillian-server", "log-server.trillian-system.svc:80", "Address of the gRPC Trillian Admin Server (host:port)")
63-
// TODO: Support ed25519
64-
keyType = flag.String("keytype", "ecdsa", "Which private key to generate [rsa,ecdsa]")
65-
curveType = flag.String("curvetype", "p256", "Curve type to use [p256, p384,p521]")
66-
keyPassword = flag.String("key-password", "test", "Password for encrypting the PEM key")
51+
privateKeySecret = flag.String("private-secret", "", "If there's an existing private key that should be used, read it from this secret.")
52+
secretName = flag.String("secret", "ctlog-secrets", "Name of the secret to create for the keyfiles")
53+
pubKeySecretName = flag.String("pubkeysecret", "ctlog-public-key", "Name of the secret to create containing only the public key")
54+
fulcioURL = flag.String("fulcio-url", "http://fulcio.fulcio-system.svc", "Where to fetch the fulcio Root CA from")
55+
keyType = flag.String("keytype", "ecdsa", "Which private key to generate [rsa,ecdsa]")
56+
curveType = flag.String("curvetype", "p256", "Curve type to use [p256, p384,p521]")
6757

6858
// Supported elliptic curve functions.
6959
supportedCurves = map[string]elliptic.Curve{
@@ -100,25 +90,6 @@ func main() {
10090
if err != nil {
10191
logging.FromContext(ctx).Panicf("Failed to get clientset: %v", err)
10292
}
103-
cm, err := clientset.CoreV1().ConfigMaps(ns).Get(ctx, *cmname, metav1.GetOptions{})
104-
if err != nil {
105-
logging.FromContext(ctx).Panicf("Failed to get the configmap %s/%s: %v", ns, *cmname, err)
106-
}
107-
108-
if cm.Data == nil {
109-
cm.Data = make(map[string]string)
110-
}
111-
treeID, ok := cm.Data[treeKey]
112-
if !ok {
113-
logging.FromContext(ctx).Errorf("No treeid yet, bailing")
114-
os.Exit(-1)
115-
}
116-
117-
logging.FromContext(ctx).Infof("Found treeid: %s", treeID)
118-
treeIDInt, err := strconv.ParseInt(treeID, 10, 64)
119-
if err != nil {
120-
logging.FromContext(ctx).Panicf("Invalid TreeID %s : %v", treeID, err)
121-
}
12293

12394
// Fetch the fulcio Root CA
12495
u, err := url.Parse(*fulcioURL)
@@ -131,97 +102,50 @@ func main() {
131102
logging.FromContext(ctx).Panicf("Failed to fetch fulcio Root cert: %w", err)
132103
}
133104

134-
// See if there's an existing configuration already in the ConfigMap
135-
var existingCMConfig []byte
136-
if cm.BinaryData != nil && cm.BinaryData[configKey] != nil {
137-
logging.FromContext(ctx).Infof("Found existing ctlog config in ConfigMap")
138-
existingCMConfig = cm.BinaryData[configKey]
139-
}
140-
141105
// See if there's existing secret with the keys we want
142106
nsSecret := clientset.CoreV1().Secrets(ns)
143107
existingSecret, err := nsSecret.Get(ctx, *secretName, metav1.GetOptions{})
144108
if err != nil && !apierrs.IsNotFound(err) {
145109
logging.FromContext(ctx).Fatalf("Failed to get secret %s/%s: %v", ns, *secretName, err)
146110
}
147111

148-
// If any of the private, public or config either from secret or configmap
149-
// is not there, create a new configuration.
150-
if existingSecret.Data[privateKey] == nil ||
151-
existingSecret.Data[publicKey] == nil ||
152-
(existingSecret.Data[configKey] == nil && existingCMConfig == nil) {
153-
var ctlogConfig *ctlog.Config
154-
var err error
155-
if *privateKeySecret != "" {
156-
// We have an existing private key, use it instead of creating
157-
// a new one.
158-
ctlogConfig, err = createConfigFromExistingSecret(ctx, nsSecret, *privateKeySecret)
159-
} else {
160-
// Create a fresh private key.
161-
ctlogConfig, err = createConfigWithKeys(ctx, *keyType)
162-
}
163-
if err != nil {
164-
logging.FromContext(ctx).Fatalf("Failed to generate keys: %v", err)
165-
}
166-
ctlogConfig.PrivKeyPassword = *keyPassword
167-
ctlogConfig.LogID = treeIDInt
168-
ctlogConfig.LogPrefix = *ctlogPrefix
169-
ctlogConfig.TrillianServerAddr = *trillianServerAddr
170-
if err = ctlogConfig.AddFulcioRoot(ctx, root.ChainPEM); err != nil {
171-
logging.FromContext(ctx).Infof("Failed to add fulcio root: %v", err)
172-
}
173-
configMap, err := ctlogConfig.MarshalConfig(ctx)
174-
if err != nil {
175-
logging.FromContext(ctx).Fatalf("Failed to marshal ctlog config: %v", err)
176-
}
177-
178-
if err := secret.ReconcileSecret(ctx, *secretName, ns, configMap, nsSecret); err != nil {
179-
logging.FromContext(ctx).Fatalf("Failed to reconcile secret: %v", err)
180-
}
181-
182-
pubData := map[string][]byte{publicKey: configMap[publicKey]}
183-
if err := secret.ReconcileSecret(ctx, *pubKeySecretName, ns, pubData, nsSecret); err != nil {
184-
logging.FromContext(ctx).Panicf("Failed to reconcile public key secret %s/%s: %v", ns, *secretName, err)
185-
}
186-
187-
logging.FromContext(ctx).Infof("Created CTLog configuration")
112+
// If either the private or public key from secret is not there, create a new configuration.
113+
if existingSecret.Data[privateKey] != nil &&
114+
existingSecret.Data[publicKey] != nil {
115+
logging.FromContext(ctx).Infof("Public and private key already exist")
188116
os.Exit(0)
189117
}
190118

191-
// Prefer the secret config if it exists, but if it doesn't use
192-
// configmap for backwards compatibility / migration.
193-
if existingSecret.Data[configKey] != nil {
194-
logging.FromContext(ctx).Infof("Found existing config in the secret, using that %s/%s", ns, *secretName)
119+
var ctlogConfig *ctlog.Config
120+
if *privateKeySecret != "" {
121+
// We have an existing private key, use it instead of creating
122+
// a new one.
123+
ctlogConfig, err = createConfigFromExistingSecret(ctx, nsSecret, *privateKeySecret)
195124
} else {
196-
existingSecret.Data[configKey] = existingCMConfig
125+
// Create a fresh private key.
126+
ctlogConfig, err = createConfigWithKeys(ctx, *keyType)
197127
}
198-
199-
existingConfig, err := ctlog.Unmarshal(ctx, existingSecret.Data)
200128
if err != nil {
201-
log.Fatalf("Failed to unmarshal existing configuration: %v", err)
129+
logging.FromContext(ctx).Fatalf("Failed to generate keys: %v", err)
202130
}
203-
204-
// Finally add Fulcio to it, marshal and write out.
205-
if err = existingConfig.AddFulcioRoot(ctx, root.ChainPEM); err != nil {
206-
log.Printf("Failed to add fulcio root: %v", err)
131+
if err = ctlogConfig.AddFulcioRoot(ctx, root.ChainPEM); err != nil {
132+
logging.FromContext(ctx).Infof("Failed to add fulcio root: %v", err)
207133
}
208-
marshaled, err := existingConfig.MarshalConfig(ctx)
134+
marshaled, err := ctlogConfig.MarshalConfig()
209135
if err != nil {
210-
log.Fatalf("Failed to marshal new configuration: %v", err)
136+
logging.FromContext(ctx).Fatalf("Failed to marshal ctlog config: %v", err)
211137
}
212-
// Take out the public / private key from the secret since we didn't mess
213-
// with those. ReconcileSecret will not touch fields that are not here, so
214-
// just remove them from the map.
215-
delete(marshaled, privateKey)
216-
delete(marshaled, publicKey)
138+
217139
if err := secret.ReconcileSecret(ctx, *secretName, ns, marshaled, nsSecret); err != nil {
218-
logging.FromContext(ctx).Panicf("Failed to reconcile secret %s/%s: %v", ns, *secretName, err)
140+
logging.FromContext(ctx).Fatalf("Failed to reconcile secret: %v", err)
219141
}
220142

221-
pubData := map[string][]byte{publicKey: existingSecret.Data[publicKey]}
143+
pubData := map[string][]byte{publicKey: marshaled[publicKey]}
222144
if err := secret.ReconcileSecret(ctx, *pubKeySecretName, ns, pubData, nsSecret); err != nil {
223-
logging.FromContext(ctx).Panicf("Failed to reconcile secret %s/%s: %v", ns, *secretName, err)
145+
logging.FromContext(ctx).Panicf("Failed to reconcile public key secret %s/%s: %v", ns, *secretName, err)
224146
}
147+
148+
logging.FromContext(ctx).Infof("Created CTLog configuration")
225149
}
226150

227151
// createConfigWithKeys creates otherwise empty CTLogCOnfig but fills
@@ -263,7 +187,7 @@ func createConfigFromExistingSecret(ctx context.Context, nsSecret v1.SecretInter
263187
if len(private) == 0 {
264188
return nil, errors.New("secret missing private key entry")
265189
}
266-
priv, pub, err := ctlog.DecryptExistingPrivateKey(private, *keyPassword)
190+
priv, pub, err := ctlog.ParseExistingPrivateKey(private)
267191
if err != nil {
268192
return nil, fmt.Errorf("decrypting existing private key secret: %w", err)
269193
}

cmd/ctlog/managectroots/main.go

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ import (
1818
"flag"
1919
"net/url"
2020
"os"
21-
"strings"
2221

2322
fulcioclient "github.com/sigstore/fulcio/pkg/api"
2423
"github.com/sigstore/scaffolding/pkg/ctlog"
25-
corev1 "k8s.io/api/core/v1"
2624
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2725
"k8s.io/client-go/kubernetes"
2826
"k8s.io/client-go/rest"
@@ -31,19 +29,10 @@ import (
3129
"sigs.k8s.io/release-utils/version"
3230
)
3331

34-
const (
35-
// Key in the configmap holding the value of the tree.
36-
treeKey = "treeID"
37-
configKey = "config"
38-
bitSize = 4096
39-
)
40-
4132
var (
42-
cmname = flag.String("configmap", "ctlog-config", "Name of the configmap where the treeID lives. if configInSecret is false, ctlog config gets added here also.")
43-
configInSecret = flag.Bool("config-in-secret", false, "If set to true, fetch / update the ctlog configuration proto into a secret specified in ctlog-secrets under key 'config'.")
44-
secretName = flag.String("secret", "ctlog-secrets", "Name of the secret to fetch private key for CTLog.")
45-
fulcioURL = flag.String("fulcio-url", "http://fulcio.fulcio-system.svc", "Where to fetch the fulcio Root CA from.")
46-
operation = flag.String("operation", "", "Operation to perform for the specified fulcio [add,remove]")
33+
secretName = flag.String("secret", "ctlog-secrets", "Name of the secret to fetch private key for CTLog.")
34+
fulcioURL = flag.String("fulcio-url", "http://fulcio.fulcio-system.svc", "Where to fetch the fulcio Root CA from.")
35+
operation = flag.String("operation", "", "Operation to perform for the specified fulcio [add,remove]")
4736
)
4837

4938
type ctRootOp string
@@ -107,27 +96,7 @@ func main() {
10796
current["private"] = secrets.Data["private"]
10897
current["public"] = secrets.Data["public"]
10998
current["rootca"] = secrets.Data["rootca"]
110-
for k, v := range secrets.Data {
111-
if strings.HasPrefix(k, "fulcio-") {
112-
current[k] = v
113-
}
114-
}
115-
// If the config is stored in the secret, we don't need to deal with the
116-
// configmap.
117-
var cm *corev1.ConfigMap
118-
if !*configInSecret {
119-
var err error
120-
cm, err = clientset.CoreV1().ConfigMaps(ns).Get(ctx, *cmname, metav1.GetOptions{})
121-
if err != nil {
122-
logging.FromContext(ctx).Panicf("Failed to get the configmap %s/%s: %v", ns, *cmname, err)
123-
}
124-
if cm.BinaryData == nil || cm.BinaryData[configKey] == nil {
125-
logging.FromContext(ctx).Fatalf("Configmap does not hold existing configmap %s/%s: %v", ns, *cmname, err)
126-
}
127-
current[configKey] = cm.BinaryData[configKey]
128-
} else {
129-
current[configKey] = secrets.Data[configKey]
130-
}
99+
current["fulcio"] = secrets.Data["fulcio"]
131100

132101
conf, err := ctlog.Unmarshal(ctx, current)
133102
if err != nil {
@@ -144,16 +113,10 @@ func main() {
144113
}
145114

146115
// Marshal it and update configuration
147-
newConfig, err := conf.MarshalConfig(ctx)
116+
newConfig, err := conf.MarshalConfig()
148117
if err != nil {
149118
logging.FromContext(ctx).Fatalf("Failed to marshal config: %v", err)
150119
}
151-
if !*configInSecret {
152-
cm.BinaryData[configKey] = newConfig[configKey]
153-
if _, err = clientset.CoreV1().ConfigMaps(ns).Update(ctx, cm, metav1.UpdateOptions{}); err != nil {
154-
logging.FromContext(ctx).Fatalf("Failed to update configmap %s/%s: %v", ns, *cmname, err)
155-
}
156-
}
157120

158121
// Update the secret with the information
159122
secrets.Data = newConfig

cmd/ctlog/verifyfulcio/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type CertResponse struct {
5151
func main() {
5252
flag.Var(&fulcioList, "fulcio", "List of fulcios which must be in the list")
5353
var ctlogURL = flag.String("ctlog-url", "ctlog.ctlog-system.svc", "CTLog to check Fulcios against.")
54-
var ctlogPrefix = flag.String("log-prefix", "sigstorescaffolding", "Prefix to append to the gtlogURL url. This is basically the name of the log.")
5554
flag.Parse()
5655
var strictMatch = flag.Bool("strict", true, "If set to true ctlog must only contain the Fulcios in the list, no more, no less")
5756
ctx := signals.NewContext()
@@ -66,7 +65,7 @@ func main() {
6665
fmt.Printf("GOT: %s\n", fulcioList.String())
6766

6867
// First grab the certs that CTLog has.
69-
ctlog := fmt.Sprintf("%s/%s/ct/v1/get-roots", *ctlogURL, *ctlogPrefix)
68+
ctlog := fmt.Sprintf("%s/ct/v1/get-roots", *ctlogURL)
7069
/* #nosec G107 */
7170
ctlogResponse, err := http.Get(ctlog)
7271
if err != nil {

config/ctlog/certs/300-createconfig.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ spec:
2121
- name: createctconfig
2222
image: ko://github.com/sigstore/scaffolding/cmd/ctlog/createctconfig
2323
args: [
24-
"--configmap=ctlog-config",
2524
"--secret=ctlog-secret"
2625
]
2726
env:

config/ctlog/createtree/100-namespace.yaml

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

config/ctlog/createtree/101-binding.yaml

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

config/ctlog/createtree/101-configmap.yaml

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

config/ctlog/createtree/101-service-account.yaml

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

0 commit comments

Comments
 (0)