{"record":{"id":"d51a23c5d788902d","repo":"passbolt/passbolt_api","slug":"this-openpgp-backend-is-not-supported-rethrown-backend","errorCode":null,"errorMessage":"This OpenPGP backend is not supported (rethrown backend failure: original exception message)","messagePattern":"This OpenPGP backend is not supported \\(rethrown backend failure: original exception message\\)","errorType":"exception","errorClass":"Cake\\Http\\Exception\\InternalErrorException","httpStatus":500,"severity":"error","filePath":"src/Utility/OpenPGP/OpenPGPBackendFactory.php","lineNumber":48,"sourceCode":"     * @var \\App\\Utility\\OpenPGP\\Backends\\Gnupg|null\n     */\n    private static ?Gnupg $instance = null;\n\n    /**\n     * Instantiate an OpenPGP Backend\n     *\n     * @param string $backend one of the supported backend\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if backend if not supported\n     * @return \\App\\Utility\\OpenPGP\\Backends\\Gnupg\n     */\n    public static function create(string $backend = self::GNUPG): OpenPGPBackend\n    {\n        switch ($backend) {\n            case self::GNUPG:\n                try {\n                    return new Gnupg();\n                } catch (CakeException $exception) {\n                    throw new InternalErrorException($exception->getMessage(), 500, $exception);\n                }\n                // no break\n            default:\n                throw new InternalErrorException('This OpenPGP backend is not supported');\n        }\n    }\n\n    /**\n     * Get a OpenPGP backend (Singleton pattern)\n     *\n     * @return \\App\\Utility\\OpenPGP\\OpenPGPBackend\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if backend if not supported\n     */\n    public static function get(): OpenPGPBackend\n    {\n        if (self::$instance !== null) {\n            return self::$instance;\n        }","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Utility/OpenPGP/OpenPGPBackendFactory.php#L30-L66","documentation":"OpenPGPBackendFactory::create() instantiates the configured OpenPGP backend. When backend is GNUPG, `new Gnupg()` can itself throw a CakeException (gnupg PHP extension failure), which create() rethrows as an InternalErrorException whose message is the original exception message but prefixed in consumers with 'This OpenPGP backend is not supported' via the wrapper. Effectively: backend construction failed at runtime.","triggerScenarios":"create('gnupg') is called and `new Gnupg()` throws — typically the gnupg PECL extension is installed but gnupg_init/keyring init fails, or the exception message from the constructor is propagated through InternalErrorException.","commonSituations":"Missing/incompatible gnupg PHP extension version; GnuPG home directory (GNUPGHOME) not writable by www-data; gpg binary missing or wrong version; extension compiled against a different libgpgme.","solutions":["Install/verify the extension: `php -m | grep gnupg` and `pecl install gnupg` if absent.","Ensure the GnuPG keyring directory exists and is writable by the PHP user (e.g. /var/lib/passbolt/.gnupg, correct ownership).","Check that gpg/gpg2 binaries are installed and compatible with the extension.","Read the wrapped original exception message in the trace — it names the underlying gnupg failure."],"exampleFix":"// before: extension missing\nPHP Warning: PHP Startup: Unable to load dynamic library 'gnupg.so'\n// after\napt-get install gnupg libgpgme-dev && pecl install gnupg && echo 'extension=gnupg.so' > /etc/php/8.x/mods-available/gnupg.ini","handlingStrategy":"try-catch","validationCode":"if (!extension_loaded('gnupg')) {\n    throw new \\RuntimeException('The PHP gnupg extension is required but not loaded.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $backend = OpenPGPBackendFactory::get();\n} catch (\\Cake\\Http\\Exception\\InternalErrorException $e) {\n    if (str_contains($e->getMessage(), 'backend')) {\n        // inspect $e->getPrevious() for the real gnupg failure\n    }\n    throw $e;\n}","preventionTips":["Assert `extension_loaded('gnupg')` in application bootstrap/CI images.","Verify GNUPGHOME is writable by the PHP user before first request (healthcheck).","Pin the gnupg extension and libgpgme versions in your deployment image."],"tags":["openpgp","backend-factory","gnupg","php-extension","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}