Skip to content

Commit

Permalink
govc: sha256 for session cache
Browse files Browse the repository at this point in the history
Use sha256 for session cache file names

This maintains compatibility between govc and Terraform, allowing
the two to share the same cache while also ensureing SHA1 is eliminated.

Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
  • Loading branch information
tenthirtyam committed Jan 24, 2025
1 parent a7d6f3a commit 0d671fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions session/cache/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package cache

import (
"context"
"crypto/sha1"
"crypto/sha256"
"encoding/json"
"fmt"
"net/url"
Expand Down Expand Up @@ -105,7 +105,7 @@ func (s *Session) key(path string) string {
// Key session file off of full URI and insecure setting.
// Hash key to get a predictable, canonical format.
key := fmt.Sprintf("%s#insecure=%t", p.String(), s.Insecure)
return fmt.Sprintf("%040x", sha1.Sum([]byte(key)))
return fmt.Sprintf("%064x", sha256.Sum256([]byte(key)))
}

func (s *Session) file(p string) string {
Expand Down

0 comments on commit 0d671fc

Please sign in to comment.