Skip to content

Commit 3b67e0e

Browse files
authored
feat(signing): implement timestamp authorities for signature and verification (chainloop-dev#1843)
Signed-off-by: Jose I. Paris <[email protected]>
1 parent 9f2781c commit 3b67e0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2337
-1175
lines changed

app/cli/internal/action/attestation_init.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,13 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
150150
return "", ErrRunnerContextNotFound{err.Error()}
151151
}
152152

153-
// Identifier of this attestation instance
154-
var attestationID string
155-
var blockOnPolicyViolation bool
153+
var (
154+
// Identifier of this attestation instance
155+
attestationID string
156+
blockOnPolicyViolation bool
157+
// Timestamp Authority URL for new attestations
158+
timestampAuthorityURL string
159+
)
156160

157161
// Init in the control plane if needed including the runner context
158162
if !action.dryRun {
@@ -176,6 +180,7 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
176180
workflowMeta.WorkflowRunId = workflowRun.GetId()
177181
workflowMeta.Organization = runResp.GetResult().GetOrganization()
178182
blockOnPolicyViolation = runResp.GetResult().GetBlockOnPolicyViolation()
183+
timestampAuthorityURL = runResp.GetResult().GetSigningOptions().GetTimestampAuthorityUrl()
179184
if v := workflowMeta.Version; v != nil {
180185
workflowMeta.Version.Prerelease = runResp.GetResult().GetWorkflowRun().Version.GetPrerelease()
181186
}
@@ -194,6 +199,7 @@ func (action *AttestationInit) Run(ctx context.Context, opts *AttestationInitRun
194199
AttestationID: attestationID,
195200
Runner: discoveredRunner,
196201
BlockOnPolicyViolation: blockOnPolicyViolation,
202+
SigningOptions: &crafter.SigningOpts{TimestampAuthorityURL: timestampAuthorityURL},
197203
}
198204

199205
if err := action.c.Init(ctx, initOpts); err != nil {

app/cli/internal/action/workflow_run_describe.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (action *WorkflowRunDescribe) Run(ctx context.Context, opts *WorkflowRunDes
246246
}
247247

248248
func trustedRootPbToVerifier(resp *pb.GetTrustedRootResponse) (*verifier.TrustedRoot, error) {
249-
tr := &verifier.TrustedRoot{Keys: make(map[string][]*x509.Certificate)}
249+
tr := &verifier.TrustedRoot{Keys: make(map[string][]*x509.Certificate), TimestampAuthorities: make(map[string][]*x509.Certificate)}
250250
for k, v := range resp.GetKeys() {
251251
for _, c := range v.Certificates {
252252
cert, err := cryptoutils.LoadCertificatesFromPEM(strings.NewReader(c))
@@ -256,6 +256,15 @@ func trustedRootPbToVerifier(resp *pb.GetTrustedRootResponse) (*verifier.Trusted
256256
tr.Keys[k] = append(tr.Keys[k], cert[0])
257257
}
258258
}
259+
for k, v := range resp.GetTimestampAuthorities() {
260+
for _, c := range v.Certificates {
261+
cert, err := cryptoutils.LoadCertificatesFromPEM(strings.NewReader(c))
262+
if err != nil {
263+
return nil, fmt.Errorf("loading certificate from PEM: %w", err)
264+
}
265+
tr.TimestampAuthorities[k] = append(tr.TimestampAuthorities[k], cert[0])
266+
}
267+
}
259268
return tr, nil
260269
}
261270

app/controlplane/api/controlplane/v1/signing.pb.go

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

app/controlplane/api/controlplane/v1/signing.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ message GetTrustedRootRequest {}
4747
message GetTrustedRootResponse {
4848
// map keyID (cert SubjectKeyIdentifier) to PEM encoded chains
4949
map<string, CertificateChain> keys = 1;
50+
// timestamp authorities
51+
map<string, CertificateChain> timestamp_authorities = 2;
5052
}

0 commit comments

Comments
 (0)