projectdiscovery/nuclei · error
failed to parse PEM block containing the private key
Error message
failed to parse PEM block containing the private key
What it means
Error "failed to parse PEM block containing the private key" thrown in projectdiscovery/nuclei.
Source
Thrown at pkg/templates/signer/handler.go:105
return err
}
if cert.Subject.CommonName == "" {
return fmt.Errorf("invalid certificate: expected common name to be set")
}
k.cert = cert
var ok bool
k.ecdsaPubKey, ok = cert.PublicKey.(*ecdsa.PublicKey)
if !ok {
return fmt.Errorf("failed to parse ecdsa public key from cert")
}
return nil
}
// ParsePrivateKey parses the private key and returns the private key
func (k *KeyHandler) ParsePrivateKey() error {
block, _ := pem.Decode(k.PrivateKey)
if block == nil {
return fmt.Errorf("failed to parse PEM block containing the private key")
}
// if pem block is encrypted , decrypt it
if x509.IsEncryptedPEMBlock(block) { // nolint: all
gologger.Info().Msgf("Private Key is encrypted with passphrase")
fmt.Printf("[*] Enter passphrase (exit to abort): ")
bin, err := term.ReadPassword(int(os.Stdin.Fd()))
if err != nil {
return err
}
fmt.Println()
if string(bin) == "exit" {
return fmt.Errorf("private key requires passphrase, but none was provided")
}
block.Bytes, err = x509.DecryptPEMBlock(block, bin) // nolint: all
if err != nil {
return err
}
}View on GitHub (pinned to 265b3a3dec)
When it happens
Trigger: Thrown at pkg/templates/signer/handler.go:105 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15).
Data as JSON: /api/errors/8d499ed97ad25ddc.
Report an issue: GitHub.