{"record":{"id":"0fc1809b165296ee","repo":"phalcon/cphalcon","slug":"this-class-requires-the-openssl-extension-for-php","errorCode":null,"errorMessage":"This class requires the openssl extension for PHP","messagePattern":"This class requires the openssl extension for PHP","errorType":"exception","errorClass":"MissingOpensslExtension","httpStatus":null,"severity":"critical","filePath":"phalcon/Encryption/Crypt.zep","lineNumber":946,"sourceCode":"         * Store the tag with encrypted data and return it. In the non AEAD\n         * mode this is an empty string\n         */\n        return encrypted . authTag;\n    }\n\n    /**\n     * Initialize available cipher algorithms.\n     *\n     * @return static\n     * @throws Exception\n     */\n    protected function initializeAvailableCiphers() -> <static>\n    {\n        var available, cipher;\n        array allowed;\n\n        if true !== this->phpFunctionExists(\"openssl_get_cipher_methods\") {\n            throw new MissingOpensslExtension();\n        }\n\n        let available = openssl_get_cipher_methods(true),\n            allowed   = [];\n\n        for cipher in available {\n            if (\n                true !== starts_with(cipher, \"des\") &&\n                true !== starts_with(cipher, \"rc2\") &&\n                true !== starts_with(cipher, \"rc4\") &&\n                true !== ends_with(cipher, \"ecb\")\n            ) {\n                let allowed[cipher] = cipher;\n            }\n        }\n\n        let this->availableCiphers = allowed;\n","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Encryption/Crypt.zep#L928-L964","documentation":"Crypt's constructor path (initializeAvailableCiphers) checks function_exists('openssl_get_cipher_methods'); if the openssl extension is not loaded it throws MissingOpensslExtension('This class requires the openssl extension for PHP'). Every Crypt operation needs OpenSSL for ciphers, IVs, and random bytes, so the class refuses to construct.","triggerScenarios":"new Crypt() (or resolving 'crypt' from the DI container, since Phalcon registers it by default) on a PHP runtime compiled/loaded without the openssl extension - typical for minimal Docker images, stripped-down shared hosts, or CLI binaries built with --disable-openssl... effectively any runtime where ext-openssl is absent.","commonSituations":"CI pipelines using slim PHP images (php:8.x-alpine without openssl); production containers built from scratch/distroless missing php-openssl; local installs where the extension line was commented out of php.ini; Windows php.ini without extension=openssl.","solutions":["Install/enable the extension: apt-get install php-openssl (Debian), apk add php8-openssl (Alpine), then restart php-fpm/CLI; on Windows uncomment extension=openssl in php.ini and ensure libcrypto/libssl DLLs are reachable.","Verify with php -m | grep openssl and function_exists('openssl_get_cipher_methods') in the exact runtime (CLI vs fpm can load different ini files).","Pin CI/deploy images so openssl presence is guaranteed, and add a boot requirement check so absence fails loudly at deploy rather than at first Crypt use."],"exampleFix":"# before: container lacks the extension\n# Fatal: Phalcon\\Encryption\\Crypt\\Exception\\MissingOpensslExtension\n\n# after (Dockerfile)\nRUN apt-get update && apt-get install -y php8.3-openssl && docker-php-ext-enable openssl\n\n# verify\nRUN php -r 'exit(function_exists(\"openssl_get_cipher_methods\") ? 0 : 1);'","handlingStrategy":"validation","validationCode":"if (!extension_loaded('openssl') || !function_exists('openssl_get_cipher_methods')) {\n    throw new \\RuntimeException('The openssl PHP extension is required by Phalcon\\Encryption\\Crypt');\n}\n$crypt = new \\Phalcon\\Encryption\\Crypt();","typeGuard":"function opensslAvailable(): bool\n{\n    return extension_loaded('openssl') && function_exists('openssl_get_cipher_methods');\n}","tryCatchPattern":"try {\n    $crypt = new \\Phalcon\\Encryption\\Crypt();\n} catch (\\Phalcon\\Encryption\\Crypt\\Exception\\MissingOpensslExtension $e) {\n    // deployment error - abort with an actionable message for ops\n    throw new \\RuntimeException('php-openssl missing: install/enable the extension and restart php-fpm', 0, $e);\n}","preventionTips":["Declare ext-openssl in composer.json (require ext-openssl: *) so composer flags it before deploy.","Bake a php -m | grep openssl check into Dockerfile/CI pipelines.","Remember CLI and fpm can load different php.ini files - verify both."],"tags":["phalcon","crypt","openssl","php-extension","environment","setup"],"backgroundTag":"missing-php-extension","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}