Just create key file if key generation is requested.

v0.4
Martin Dosch 2 years ago
parent 0279deae17
commit 07d3491c2a

16
ox.go

@ -169,16 +169,9 @@ func oxGetPrivKey(jid string, passphrase string) (*crypto.Key, error) {
func oxStoreKey(location string, key string) error {
var file *os.File
if _, err := os.Stat(location); os.IsNotExist(err) {
file, err = os.Create(location)
if err != nil {
return err
}
} else {
file, err = os.OpenFile(location, os.O_RDWR, os.FileMode(0600))
if err != nil {
return err
}
file, err := os.Create(location)
if err != nil {
return err
}
defer file.Close()
if runtime.GOOS != "windows" {
@ -186,11 +179,10 @@ func oxStoreKey(location string, key string) error {
} else {
_ = file.Chmod(os.FileMode(0200))
}
_, err := file.Write([]byte(key))
_, err = file.Write([]byte(key))
if err != nil {
return err
}
return nil
}

Loading…
Cancel
Save