phalcon/cphalcon · error · EmptyPassphrase
Invalid passphrase (empty)
Error message
Invalid passphrase (empty)
What it means
Thrown by JWT Builder::getToken when the passphrase was never set (empty), because producing the HMAC signature requires a secret key. Call Builder::setPassphrase() with a non-empty secret before requesting the token.
Solutions
- Call setPassphrase() with a strong passphrase before getToken()
- Ensure the passphrase is not an empty string after trimming/config loading
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phalcon/Encryption/Security/JWT/Builder.zep:210 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/ab78d4b1a1197136.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Encryption/Security/JWT/Builder.zep:210
/**
* @return string|null
*/
public function getSubject() -> string | null
{
return this->claims->get(Enum::SUBJECT, null, "string");
}
/**
* @return Token
* @throws ValidatorException
*/
public function getToken() -> <Token>
{
var claims, encodedClaims, encodedHeaders, encodedSignature,
headers, signature, signatureHash;
if empty this->passphrase {
throw new EmptyPassphrase();
}
let encodedClaims = this->doEncodeUrl(this->encode->__invoke(this->getClaims())),
claims = new Item(this->getClaims(), encodedClaims),
encodedHeaders = this->doEncodeUrl(this->encode->__invoke(this->getHeaders())),
headers = new Item(this->getHeaders(), encodedHeaders),
signatureHash = this->signer->sign(
encodedHeaders . "." . encodedClaims,
this->passphrase
),
encodedSignature = this->doEncodeUrl(signatureHash),
signature = new Signature(signatureHash, encodedSignature);
return new Token(headers, claims, signature);
}
/**
* @return staticView on GitHub (pinned to b7419de9cd)