This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ParsePKCS8PrivateKey(der []byte, v ...[]byte) (interface{}, error) { | |
// No password provided, assume the private key is unencrypted | |
if v == nil || len(v[0]) == 0 { | |
return x509.ParsePKCS8PrivateKey(der) | |
} | |
// Use the password provided to decrypt the private key | |
password := v[0] | |
var privKey encryptedPrivateKeyInfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func ConvertPrivateKeyToPKCS8(priv interface{}, v ...[]byte) ([]byte, error) { | |
if v == nil { | |
return convertPrivateKeyToPKCS8(priv) | |
} | |
password := string(v[0]) | |
return convertPrivateKeyToPKCS8Encrypted(priv, []byte(password)) |