// PrivateKeyFromPEM private key pem.
PrivateKeyFromPEM private key pem.
// PrivateKeyFromPEM private key pem .
func PrivateKeyFromPEM(privateKeyPEM, password []byte) (crypto.PrivateKey, error) {
	privBlock, _ := pem.Decode(privateKeyPEM)
	if privBlock == nil {
		return nil, fmt.Errorf("private key not found in PEM")
	}
	b := privBlock.Bytes
	if len(password) != 0 {
		var err error
		b, err = x509.DecryptPEMBlock(privBlock, password) 
		if err != nil {
			return nil, err
		}
	}
	privKey, err := ParsePrivateKey(b)
	if err != nil {
		return nil, err
	}
	return privKey, nil
}
func PrivateKeyFromPEM ( privateKeyPEM , password [ ] byte ) ( crypto . PrivateKey , error ) { privBlock , _ := pem . Decode ( privateKeyPEM ) if privBlock == nil { return nil , fmt . Errorf ( " " ) } b := privBlock . Bytes if len ( password ) != 0 { var err error b , err = x509 . DecryptPEMBlock ( privBlock , password ) if err != nil { return nil , err } } privKey , err := ParsePrivateKey ( b ) if err != nil { return nil , err } return privKey , nil }
PrivateKeyFromPEM private key pem.
PrivateKeyFromPEM private key pem .
// FIXME: x509.DecryptPEMBlock deprecated in go1.16 due to security flaws. //   this should be replaced by a different infrastructure for configuring keys before this goes into prod. //nolint:staticcheck