projectdiscovery/nuclei · error
invalid certificate: expected common name to be set
Error message
invalid certificate: expected common name to be set
What it means
Error "invalid certificate: expected common name to be set" thrown in projectdiscovery/nuclei.
Source
Thrown at pkg/templates/signer/handler.go:90
if privateKey, err := os.ReadFile(filepath.Join(dir, PrivateKeyFilename)); err == nil {
k.PrivateKey = privateKey
return nil
}
return ErrNoPrivateKey
}
// ParseUserCert parses the user certificate and returns the public key
func (k *KeyHandler) ParseUserCert() error {
block, _ := pem.Decode(k.UserCert)
if block == nil {
return fmt.Errorf("failed to parse PEM block containing the certificate")
}
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
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: allView on GitHub (pinned to 265b3a3dec)
When it happens
Trigger: Thrown at pkg/templates/signer/handler.go:90 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15).
Data as JSON: /api/errors/a5d031d2e6874c0f.
Report an issue: GitHub.