Fix certificate renewal (#209)

A database bug in xorm.go prevents the pages-server from saving a
renewed certificate for a domain that already has one in the database.

Co-authored-by: crystal <crystal@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/209
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Crystal <crystal@noreply.codeberg.org>
Co-committed-by: Crystal <crystal@noreply.codeberg.org>
This commit is contained in:
Crystal 2023-03-20 22:57:26 +00:00 committed by 6543
parent 26d59b71f0
commit c40dddf471
2 changed files with 2 additions and 2 deletions

View file

@ -64,7 +64,7 @@ func (x xDB) Put(domain string, cert *certificate.Resource) error {
}
defer sess.Close()
if exist, _ := sess.ID(c.Domain).Exist(); exist {
if exist, _ := sess.ID(c.Domain).Exist(new(Cert)); exist {
if _, err := sess.ID(c.Domain).Update(c); err != nil {
return err
}

View file

@ -37,7 +37,7 @@ func TestSanitizeWildcardCerts(t *testing.T) {
}))
// update existing cert
assert.Error(t, certDB.Put(".wildcard.de", &certificate.Resource{
assert.NoError(t, certDB.Put(".wildcard.de", &certificate.Resource{
Domain: "*.wildcard.de",
Certificate: localhost_mock_directory_certificate,
}))