-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sc-8652: Handle Expired Certificates in Certman #972
Conversation
4632fe4
to
f43f1e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, I did have a few suggestions before merging but they should be fairly straightforward.
pkg/gds/certman/certs.go
Outdated
@@ -824,6 +835,10 @@ vaspsLoop: | |||
} | |||
} | |||
|
|||
func RetrieveCertID(identityCert *pb.Certificate) string { | |||
return fmt.Sprintf("%X", identityCert.SerialNumber) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like this helper, however I think we can make it a bit more useful by moving it to the models
package (pkg/models/v1
) so other packages can use it. Then, let's replace all instances where we are encoding the serial number with this helper method so that we can standardize that a bit more (basically just search the repo for fmt.Sprintf("%X
).
Also since we're moving it to a different package can we change the name of the method to GetCertID
or something along those lines to better match the naming conventions there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea!
pkg/gds/certman/certs.go
Outdated
continue vaspsLoop | ||
} | ||
cert.Status = models.CertificateState_EXPIRED | ||
c.db.UpdateCert(cert) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle any errors returned by UpdateCert
here, my first instinct is that we don't need to bail out of the loop or anything but I think we should at least log the error. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! I hadn't notice UpdateCert returning an error, my bad!
s.updateVaspIdentityCert(charlieVASP, 6) | ||
s.updateVaspIdentityCert(hotelVASP, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this test failing? I don't understand why this line is necessary now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, hotelVASP's cert is expired so it was triggering the <= 7 days before expiration
case by default, but now since we have a <= 0 days before expiration
case it was triggering that and throwing off the expected emails and causing the test to fail, so I added this line to update it's cert expiration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes complete sense, thanks.
pkg/gds/certman/certs_test.go
Outdated
defer s.fixtures.LoadReferenceFixtures() | ||
require := s.Require() | ||
|
||
// setup the datastore to contain the modified charlieVASP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// setup the datastore to contain the modified charlieVASP | |
// Setup the datastore to contain the modified hotelVASP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
|
||
cert, err = s.db.RetrieveCert(certID) | ||
require.NoError(err) | ||
require.Equal(cert.Status, models.CertificateState_EXPIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So hotelVASP
has an expired certificate by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, see the above comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes, I had an additional suggestion to add a docstring but other than that feel free to merge when you're ready.
Scope of changes
Updates the Certman reissuance loop to handle the case where the certificate has expired.
Type of change
Acceptance criteria
Describe how reviewers can test this change to be sure that it works correctly. Add a checklist if possible
Author checklist
Reviewer(s) checklist