Be explicit abot files when managing keys.

This commit is contained in:
Mariano Uvalle 2023-11-12 06:58:55 +00:00
parent 39798f50f7
commit 8fa3d44d67
3 changed files with 10 additions and 10 deletions

View file

@ -55,20 +55,20 @@ func Write(c ConfigFile) error {
func LoadPrivateKey() (*ecdh.PrivateKey, error) {
fp := path.Join(Path, PrivateKeyFileName)
return crypto.LoadPrivateKey(fp)
return crypto.LoadPrivateKeyFromFile(fp)
}
func LoadPublicKey() (*ecdh.PublicKey, error) {
fp := path.Join(Path, PublicKeyFileName)
return crypto.LoadPublicKey(fp)
return crypto.LoadPublicKeyFromFile(fp)
}
func SavePrivateKey(k *ecdh.PrivateKey) error {
fp := path.Join(Path, PrivateKeyFileName)
return crypto.SavePrivateKey(fp, k)
return crypto.SavePrivateKeyToFile(fp, k)
}
func SavePublicKey(k *ecdh.PublicKey) error {
fp := path.Join(Path, PublicKeyFileName)
return crypto.SavePublicKey(fp, k)
return crypto.SavePublicKeyToFile(fp, k)
}

View file

@ -37,11 +37,11 @@ type controller struct {
func newHttpHandler() http.Handler {
r := mux.NewRouter()
pbk, err := crypto.LoadPublicKey(config.Default.PublicKeyPath)
pbk, err := crypto.LoadPublicKeyFromFile(config.Default.PublicKeyPath)
if err != nil {
panic("could not load server's public key")
}
pvk, err := crypto.LoadPrivateKey(config.Default.PrivateKeyPath)
pvk, err := crypto.LoadPrivateKeyFromFile(config.Default.PrivateKeyPath)
if err != nil {
panic("could not load server's private key")
}