Skip to content
Snippets Groups Projects
Commit e577dc88 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Use error wrapper

parent 378d3888
No related branches found
No related tags found
No related merge requests found
......@@ -12,13 +12,14 @@ import (
gorsa "crypto/rsa"
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
"github.com/pkg/errors"
)
// LoadPrivateKeyFromPem decodes and produces an RSA PrivateKey in PKCS#1 PEM
// format
// Usage:
//
// pem := ioutil.ReadFile("pemfile.pem")
// privateKey, err := LoadPrivateKeyFromPem(pem)
func LoadPrivateKeyFromPem(pemBytes []byte) (*PrivateKey, error) {
......@@ -44,8 +45,7 @@ func LoadPrivateKeyFromPem(pemBytes []byte) (*PrivateKey, error) {
}
if err != nil {
return nil, errors.New(
fmt.Sprintf("could not decode key from PEM: %+v", err))
return nil, errors.Wrap(err, "could not decode key from PEM")
}
keyRSA, success := key.(*gorsa.PrivateKey)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment