add parser

This commit is contained in:
toshikihigaki 2019-07-26 16:30:49 +09:00
parent 5e25c22bd5
commit e02edc50e4
1 changed files with 3 additions and 1 deletions

View File

@ -25,8 +25,10 @@ func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) {
// Parse the key // Parse the key
var parsedKey interface{} var parsedKey interface{}
if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil { if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil {
if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
return nil, err return nil, err
} }
}
var pkey *ecdsa.PrivateKey var pkey *ecdsa.PrivateKey
var ok bool var ok bool