Move certificate verification code to VerifyConnection

This commit is contained in:
adnano
2020-10-13 16:44:46 -04:00
parent db89a34935
commit 3d1e9e5519
7 changed files with 18 additions and 60 deletions

View File

@@ -29,7 +29,7 @@ func init() {
// Alert the user that the certificate is not trusted
fmt.Printf("Warning: Certificate for %s is not trusted!\n", hostname)
fmt.Println("This could indicate a Man-in-the-Middle attack.")
case gmi.ErrUnknownCertificate:
case gmi.ErrCertificateUnknown:
// Prompt the user to trust the certificate
trust := trustCertificate(cert)
switch trust {

View File

@@ -19,7 +19,7 @@ func main() {
cert, err := store.Lookup(hostname)
if err != nil {
switch err {
case gmi.ErrInvalidCertificate:
case gmi.ErrCertificateExpired:
log.Print("Old certificate expired, creating new one")
// Generate a new certificate if the old one is expired.
crt, key, err := gmi.NewRawCertificate(hostname, time.Minute)