Use pkcs1 private key parser
This commit is contained in:
10
sign.go
10
sign.go
@@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"crypto"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
@@ -85,16 +84,11 @@ func main() {
|
||||
log.Fatal(errors.New("failed to parse PEM block containing the private key"))
|
||||
}
|
||||
|
||||
pkey, err := x509.ParsePKCS8PrivateKey(key_data_block.Bytes)
|
||||
pkey, err := x509.ParsePKCS1PrivateKey(key_data_block.Bytes)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
key, ok := pkey.(crypto.Signer)
|
||||
if !ok {
|
||||
log.Fatal(errors.New("private key does not implement crypto.Signer"))
|
||||
}
|
||||
|
||||
err = sign.SignFile(input, output, sign.SignData{
|
||||
Signature: sign.SignDataSignature{
|
||||
Info: sign.SignDataSignatureInfo{
|
||||
@@ -105,7 +99,7 @@ func main() {
|
||||
Date: time.Now().Local(),
|
||||
},
|
||||
},
|
||||
Signer: key,
|
||||
Signer: pkey,
|
||||
Certificate: cert,
|
||||
})
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user