Activity-Relay/KeyLoader/keyloader.go
2021-06-18 09:25:55 +09:00

22 lines
379 B
Go

package keyloader
import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"io/ioutil"
)
func ReadPrivateKeyRSAfromPath(path string) (*rsa.PrivateKey, error) {
file, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
decoded, _ := pem.Decode(file)
priv, err := x509.ParsePKCS1PrivateKey(decoded.Bytes)
if err != nil {
return nil, err
}
return priv, nil
}