-
Notifications
You must be signed in to change notification settings - Fork 1
Cert expired checker #4
base: volt-certificate-provider
Are you sure you want to change the base?
Cert expired checker #4
Conversation
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.
@orbitalturtle This looks awesome and I love how you reformatted the ZeroSSL service. Few comments for the initial review. I can start testing once we straighten those out.
Also looks like it could use a make fmt
lnd.go
Outdated
func CheckForExpiredCert(certprovider certprovider.CertProvider, certId string) bool { | ||
cert, err := certprovider.GetCert(certId) | ||
if err != nil { | ||
fmt.Errorf("error retrieving ZeroSSL certificate: %v", err) |
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.
Do we need a return here? Maybe if there's an error return false
lnd.go
Outdated
|
||
// CheckForExpiredCert finds whether the TLS certificate is expiring soon. | ||
func CheckForExpiredCert(certprovider certprovider.CertProvider, certId string) bool { | ||
cert, err := certprovider.GetCert(certId) |
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.
Interesting choice calling to ZeroSSL to check the expiration date. I actually didn't even think about that. My approach would have been to read the tls.cert
from disk and check it's expiration date from that. What's your opinion on one versus the other? I think I'm slightly worried that this could get out of step with what the API returns and what the certificate actually is. That might be a super rare case, but could be a crazy happening nonetheless.
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.
Ohh that's a good point. Let's read from disk to be safe. Also just in terms of the API potentially going down sometimes and whatnot
lnd.go
Outdated
keyBytes, err = lnencrypt.DecryptPayloadFromReader(reader, activeChainControl.KeyRing) | ||
if err != nil { | ||
ltndLog.Error(err) | ||
// return err |
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 see you commented out the error, should we return errors from this function?
lnd.go
Outdated
if err != nil { | ||
ltndLog.Error("Failed to revoke temporary certifiate:") | ||
ltndLog.Error(err) | ||
} | ||
// Switch the server's TLS certificate to the persisntent one | ||
// Switch the server's TLS certificate to the persistent one | ||
err = tlsReloader.AttemptReload(certBytes, keyBytes) |
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.
Should this bit of code be replaced by the new DeleteAndRegenerateCert
function? I'm not exactly sure but looks like maybe it can?
@gkrizek Thanks for the review! I'll fix those things up. Are you able to give me an example output of the full JSON that the download endpoint gives (https://zerossl.com/documentation/api/download-certificate-inline/)? That'll actually help with one of these changes |
Sorry! Forgot about this part. Here's an example response:
|
303ec1e
to
dbc68eb
Compare
@gkrizek Here's a refreshed version! I believe most of the new code is test-related |
Looking over it again I think this look good. I'll test this soon too. Thanks! |
Pull Request Checklist
Contribution Guidelines
the positive and negative (error paths) conditions (if applicable)
the bug being fixed to prevent regressions
logging level
go fmt
lnrpc/**/*.proto
) have been formatted withmake rpc-format
and compiled withmake rpc
sample-lnd.conf
(the tab character should be counted as 8 characters, not 4, as some IDEs do
per default)
make check
does not fail any testsgo vet
does not report any issuesmake lint
does not report any new issues that did notalready exist
cases it can be justifiable to violate this condition. In that case, the
reason should be stated in the commit message.