|
|
|
@ -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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|