Files
Reseed_Tools/cmd/utils.go

29 lines
482 B
Go
Raw Normal View History

2014-12-11 00:05:41 -06:00
package cmd
import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"io/ioutil"
2014-12-14 19:37:42 -06:00
"strings"
2014-12-11 00:05:41 -06:00
)
func loadPrivateKey(path string) (*rsa.PrivateKey, error) {
privPem, err := ioutil.ReadFile(path)
if nil != err {
return nil, err
}
2014-12-11 11:11:12 -06:00
2014-12-11 00:05:41 -06:00
privDer, _ := pem.Decode(privPem)
privKey, err := x509.ParsePKCS1PrivateKey(privDer.Bytes)
if nil != err {
return nil, err
}
return privKey, nil
}
2014-12-14 19:37:42 -06:00
func signerFile(signerId string) string {
return strings.Replace(signerId, "@", "_at_", 1)
}