This commit is contained in:
Stéphane Depierrepont aka Toorop
2015-05-14 10:27:40 +02:00
parent 016293cce9
commit 773c7cd060
4 changed files with 54 additions and 17 deletions

View File

@@ -43,7 +43,7 @@ type sigOptions struct {
Version uint
// Private key used for signing (required)
PrivateKey string
PrivateKey []byte
// Domain (required)
Domain string
@@ -101,10 +101,10 @@ func Sign(email *[]byte, options sigOptions) error {
var privateKey *rsa.PrivateKey
// PrivateKey
if options.PrivateKey == "" {
if len(options.PrivateKey) == 0 {
return ErrSignPrivateKeyRequired
}
d, _ := pem.Decode([]byte(options.PrivateKey))
d, _ := pem.Decode(options.PrivateKey)
key, err := x509.ParsePKCS1PrivateKey(d.Bytes)
if err != nil {
return ErrCandNotParsePrivateKey