Skip to content

Commit

Permalink
Use SHA512 checksum instead of MD5
Browse files Browse the repository at this point in the history
  • Loading branch information
zbud-msft committed Feb 1, 2024
1 parent 0943d7f commit 73ce72d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"crypto/tls"
"crypto/x509"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"flag"
"io"
Expand Down Expand Up @@ -114,10 +114,10 @@ func main() {
}
certificate, err = tls.LoadX509KeyPair(*serverCert, *serverKey)
if err != nil {
validateSHA512(*serverCert)
validateSHA512(*serverKey)
log.Exitf("could not load server key pair: %s", err)
}
validateSHA256(*serverCert)
validateSHA256(*serverKey)
}

tlsCfg := &tls.Config{
Expand Down Expand Up @@ -211,18 +211,18 @@ func getflag(name string) string {
return val
}

func validateSHA256(file string) {
func validateSHA512(file string) {
currentTime := time.Now().UTC()
f, err := os.Open(file)
if err != nil {
log.Errorf("Unable to open %s, got err %s", file, err)
}
defer f.Close()

hasher := sha256.New()
hasher := sha512.New()
if _, err := io.Copy(hasher, f); err != nil {
log.Errorf("Unable to create hash for %s, got err %s", file, err)
}
hash := hasher.Sum(nil)
log.V(1).Infof("SHA256 hash of %s: %s at time %s", file, hex.EncodeToString(hash), currentTime.String())
log.V(1).Infof("SHA512 hash of %s: %s at time %s", file, hex.EncodeToString(hash), currentTime.String())
}

0 comments on commit 73ce72d

Please sign in to comment.