Skip to content

Commit 6f516bc

Browse files
committed
fix: restore duplicate SKI validation fallback
1 parent f171851 commit 6f516bc

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

RALPH.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,10 @@ Area: [cmd/certkit/tree.go](cmd/certkit/tree.go), [cmd/certkit/cli_semantics_tes
238238
Summary: the default `tree` output included every local and inherited flag, which made the command map harder to scan than a command-focused tree.
239239
Source: User feedback
240240
Fix: `tree` now defaults to commands-only text output, with `--flags` and `--inherited` opt-ins for text-mode flag detail; JSON output remains the detailed machine-readable surface
241+
242+
34. `validate-duplicate-ski-fallback`
243+
Status: fixed
244+
Area: [internal/certstore/validate.go](internal/certstore/validate.go), [internal/certstore/validate_test.go](internal/certstore/validate_test.go)
245+
Summary: validation errored on duplicate-SKI renewal sets even though the rest of the store/UI already presents one latest-expiring certificate per SKI.
246+
Source: Follow-up PR review
247+
Fix: `RunValidation()` now uses the store's latest-cert selection for a given SKI, and the regression test proves the later renewal is the record that gets validated

internal/certstore/validate.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
)
1717

1818
var errValidationCertNotFound = errors.New("certificate with SKI not found")
19-
var errValidationCertAmbiguous = errors.New("multiple certificates share SKI")
2019

2120
// ValidationResult holds the outcome of validating a single certificate.
2221
type ValidationResult struct {
@@ -46,14 +45,10 @@ func RunValidation(ctx context.Context, input RunValidationInput) (*ValidationRe
4645
skiHex := strings.ReplaceAll(input.SKIColon, ":", "")
4746
skiHex = strings.ToLower(skiHex)
4847

49-
certs := input.Store.CertsForSKI(skiHex)
50-
if len(certs) == 0 {
48+
rec := input.Store.GetCert(skiHex)
49+
if rec == nil {
5150
return nil, fmt.Errorf("%w: %s", errValidationCertNotFound, input.SKIColon)
5251
}
53-
if len(certs) > 1 {
54-
return nil, fmt.Errorf("%w: %s", errValidationCertAmbiguous, input.SKIColon)
55-
}
56-
rec := certs[0]
5752

5853
leaf := rec.Cert
5954
now := time.Now()

internal/certstore/validate_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func TestRunValidation(t *testing.T) {
488488
Subject: pkix.Name{CommonName: "renewal-two.example.com"},
489489
DNSNames: []string{"renewal-two.example.com"},
490490
NotBefore: time.Now().Add(-time.Hour),
491-
NotAfter: time.Now().Add(365 * 24 * time.Hour),
491+
NotAfter: time.Now().Add(366 * 24 * time.Hour),
492492
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,
493493
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
494494
}
@@ -516,8 +516,15 @@ func TestRunValidation(t *testing.T) {
516516
}
517517
return store, skiToColonHex(t, hexSKI)
518518
},
519-
wantErr: true,
520-
errContains: "multiple certificates share SKI",
519+
validate: func(t *testing.T, result *ValidationResult) {
520+
t.Helper()
521+
if result.Subject != "renewal-two.example.com" {
522+
t.Fatalf("Subject = %q, want renewal-two.example.com", result.Subject)
523+
}
524+
if result.NotAfter == "" {
525+
t.Fatal("NotAfter should not be empty")
526+
}
527+
},
521528
},
522529
}
523530

0 commit comments

Comments
 (0)