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 }