mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-21 11:50:01 +00:00
fix: couldn't trasform ecc certificate to pfx format
This commit is contained in:
parent
6adcc61447
commit
d28b89f03e
@ -2,6 +2,8 @@
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/ecdsa"
|
||||
"crypto/rsa"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"time"
|
||||
@ -26,10 +28,24 @@ func TransformCertificateFromPEMToPFX(certPem string, privkeyPem string, pfxPass
|
||||
return nil, err
|
||||
}
|
||||
|
||||
privkey, err := ParsePKCS1PrivateKeyFromPEM(privkeyPem)
|
||||
var privkey interface{}
|
||||
switch cert.PublicKey.(type) {
|
||||
case *rsa.PublicKey:
|
||||
{
|
||||
privkey, err = ParsePKCS1PrivateKeyFromPEM(privkeyPem)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
case *ecdsa.PublicKey:
|
||||
{
|
||||
privkey, err = ParseECPrivateKeyFromPEM(privkeyPem)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pfxData, err := pkcs12.LegacyRC2.Encode(privkey, cert, nil, pfxPassword)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user