Fix handling of ErrDuplicate in AddSCTReceipt.
This commit is contained in:
parent
a46617ea5d
commit
a181d8b0b6
|
|
@ -1200,14 +1200,7 @@ func NewStorageAuthorityServer(rpc Server, impl core.StorageAuthority) error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = impl.AddSCTReceipt(core.SignedCertificateTimestamp(sct))
|
return nil, impl.AddSCTReceipt(core.SignedCertificateTimestamp(sct))
|
||||||
if err != nil {
|
|
||||||
// AUDIT[ Error Conditions ] 9cc4d537-8534-4970-8665-4b382abe82f3
|
|
||||||
errorCondition(MethodAddSCTReceipt, err, req)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, nil
|
|
||||||
})
|
})
|
||||||
|
|
||||||
rpc.Handle(MethodCountFQDNSets, func(req []byte) (response []byte, err error) {
|
rpc.Handle(MethodCountFQDNSets, func(req []byte) (response []byte, err error) {
|
||||||
|
|
|
||||||
|
|
@ -897,18 +897,15 @@ func (ssa *SQLStorageAuthority) GetSCTReceipt(serial string, logID string) (rece
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrDuplicateReceipt is an error type for duplicate SCT receipts
|
|
||||||
type ErrDuplicateReceipt string
|
|
||||||
|
|
||||||
func (e ErrDuplicateReceipt) Error() string {
|
|
||||||
return string(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddSCTReceipt adds a new SCT receipt to the (append-only) sctReceipts table
|
// AddSCTReceipt adds a new SCT receipt to the (append-only) sctReceipts table
|
||||||
func (ssa *SQLStorageAuthority) AddSCTReceipt(sct core.SignedCertificateTimestamp) error {
|
func (ssa *SQLStorageAuthority) AddSCTReceipt(sct core.SignedCertificateTimestamp) error {
|
||||||
err := ssa.dbMap.Insert(&sct)
|
err := ssa.dbMap.Insert(&sct)
|
||||||
|
// For AddSCTReceipt, duplicates are explicitly OK, so don't return errors
|
||||||
|
// based on duplicates, especially because we currently retry all submissions
|
||||||
|
// for a certificate if even one of them fails. Once https://github.com/letsencrypt/boulder/issues/891
|
||||||
|
// is fixed, we may want to start returning this as an error, or logging it.
|
||||||
if err != nil && strings.HasPrefix(err.Error(), "Error 1062: Duplicate entry") {
|
if err != nil && strings.HasPrefix(err.Error(), "Error 1062: Duplicate entry") {
|
||||||
err = ErrDuplicateReceipt(err.Error())
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ func initSA(t *testing.T) (*SQLStorageAuthority, clock.FakeClock, func()) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create dbMap: %s", err)
|
t.Fatalf("Failed to create dbMap: %s", err)
|
||||||
}
|
}
|
||||||
dbMap.TraceOn("SQL: ", &SQLLogger{log})
|
|
||||||
|
|
||||||
fc := clock.NewFake()
|
fc := clock.NewFake()
|
||||||
fc.Set(time.Date(2015, 3, 4, 5, 0, 0, 0, time.UTC))
|
fc.Set(time.Date(2015, 3, 4, 5, 0, 0, 0, time.UTC))
|
||||||
|
|
@ -471,8 +470,7 @@ func TestAddSCTReceipt(t *testing.T) {
|
||||||
test.AssertNotError(t, err, "Failed to add SCT receipt")
|
test.AssertNotError(t, err, "Failed to add SCT receipt")
|
||||||
// Append only and unique on signature and across LogID and CertificateSerial
|
// Append only and unique on signature and across LogID and CertificateSerial
|
||||||
err = sa.AddSCTReceipt(sct)
|
err = sa.AddSCTReceipt(sct)
|
||||||
test.AssertError(t, err, "Incorrectly added duplicate SCT receipt")
|
test.AssertNotError(t, err, "Incorrectly returned error on duplicate SCT receipt")
|
||||||
fmt.Println(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSCTReceipt(t *testing.T) {
|
func TestGetSCTReceipt(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue