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