sa: Truncate notBefore times on issuedNames (#7568)

We only care about the date of an issuedName, not the exact time, and
this may reduce the size of the index somewhat.

---------

Co-authored-by: Samantha Frank <hello@entropy.cat>
This commit is contained in:
Jacob Hoffman-Andrews 2024-07-03 08:11:59 -07:00 committed by GitHub
parent 0068f02680
commit 926a0704b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View File

@ -1008,7 +1008,7 @@ func addIssuedNames(ctx context.Context, queryer db.Queryer, cert *x509.Certific
err = multiInserter.Add([]interface{}{ err = multiInserter.Add([]interface{}{
ReverseName(name), ReverseName(name),
core.SerialToString(cert.SerialNumber), core.SerialToString(cert.SerialNumber),
cert.NotBefore, cert.NotBefore.Truncate(24 * time.Hour),
isRenewal, isRenewal,
}) })
if err != nil { if err != nil {

View File

@ -1077,6 +1077,7 @@ func TestAddIssuedNames(t *testing.T) {
serial := big.NewInt(1) serial := big.NewInt(1)
expectedSerial := "000000000000000000000000000000000001" expectedSerial := "000000000000000000000000000000000001"
notBefore := time.Date(2018, 2, 14, 12, 0, 0, 0, time.UTC) notBefore := time.Date(2018, 2, 14, 12, 0, 0, 0, time.UTC)
expectedNotBefore := notBefore.Truncate(24 * time.Hour)
placeholdersPerName := "(?,?,?,?)" placeholdersPerName := "(?,?,?,?)"
baseQuery := "INSERT INTO issuedNames (reversedName,serial,notBefore,renewal) VALUES" baseQuery := "INSERT INTO issuedNames (reversedName,serial,notBefore,renewal) VALUES"
@ -1097,7 +1098,7 @@ func TestAddIssuedNames(t *testing.T) {
ExpectedArgs: []interface{}{ ExpectedArgs: []interface{}{
"uk.co.example", "uk.co.example",
expectedSerial, expectedSerial,
notBefore, expectedNotBefore,
false, false,
}, },
}, },
@ -1110,11 +1111,11 @@ func TestAddIssuedNames(t *testing.T) {
ExpectedArgs: []interface{}{ ExpectedArgs: []interface{}{
"uk.co.example", "uk.co.example",
expectedSerial, expectedSerial,
notBefore, expectedNotBefore,
false, false,
"xyz.example", "xyz.example",
expectedSerial, expectedSerial,
notBefore, expectedNotBefore,
false, false,
}, },
}, },
@ -1127,7 +1128,7 @@ func TestAddIssuedNames(t *testing.T) {
ExpectedArgs: []interface{}{ ExpectedArgs: []interface{}{
"uk.co.example", "uk.co.example",
expectedSerial, expectedSerial,
notBefore, expectedNotBefore,
true, true,
}, },
}, },
@ -1140,11 +1141,11 @@ func TestAddIssuedNames(t *testing.T) {
ExpectedArgs: []interface{}{ ExpectedArgs: []interface{}{
"uk.co.example", "uk.co.example",
expectedSerial, expectedSerial,
notBefore, expectedNotBefore,
true, true,
"xyz.example", "xyz.example",
expectedSerial, expectedSerial,
notBefore, expectedNotBefore,
true, true,
}, },
}, },