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{}{
ReverseName(name),
core.SerialToString(cert.SerialNumber),
cert.NotBefore,
cert.NotBefore.Truncate(24 * time.Hour),
isRenewal,
})
if err != nil {

View File

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