Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Startup: Unable to load dynamic library 'gnupg.so' (tried: /opt/bref/extensions/gnupg.so (libgpgme.so.11: cannot open shared object file: No such file or directory) #443

Closed
mdschertz opened this issue May 10, 2023 · 8 comments

Comments

@mdschertz
Copy link

When using the gnupg-php-82 this error message appears in the Cloudwatch logs for the Lambda function.

@mnapoli
Copy link
Member

mnapoli commented May 10, 2023

We will need more details to help.

@mdschertz
Copy link
Author

mdschertz commented May 12, 2023

I've been digging into it and I think I have found the issue although not the solution yet. The problem is that libgpgme.so.11 and libassuan.so.0 aren't in any of the library paths. I created a layer that added them which appears to work but then has a libc version mismatch error.

It's easy to replicate using this serverless.yml:

service: PGP-Encrypt

provider:
name: aws
region: us-east-1

plugins:
- ./vendor/bref/bref
- ./vendor/bref/extra-php-extensions

functions:
Encrypt:
handler: test.php
layers:
- ${bref-extra:gnupg-php-81}
description: ''
runtime: php-81-fpm
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
events:
- httpApi: '*'

package:
patterns:
- '!node_modules/'
- '!tests/
'

And the test.php file from the repo in the gnupg layer

@SyuTingSong
Copy link

SyuTingSong commented Jan 25, 2024

Similar issue in PHP 8.3. A warning instead of initial error was reported.

Warning: PHP Startup: Unable to load dynamic library 'gnupg.so' (tried: /opt/bref/extensions/gnupg.so (libgpgme.so.11: cannot open shared object file: No such file or directory), /opt/bref/extensions/gnupg.so.so (/opt/bref/extensions/gnupg.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Here are my project files.

composer.json:

{
    "require": {
        "bref/bref": "^2.1.12",
        "bref/extra-php-extensions": "^1.4.0"
    }
}

serverless.yml

service: bref-demo

provider:
    name: aws
    region: us-east-1

plugins:
    - ./vendor/bref/bref
    - ./vendor/bref/extra-php-extensions

functions:
    hello:
        handler: index.php
        description: ''
        runtime: php-83
        layers:
            - ${bref-extra:gnupg-php-83}

# Exclude files from deployment
package:
    patterns:
        - '!tests/**'

index.php:

<?php declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

return function ($event) {
    phpinfo();
    return 'Hello ' . ($event['name'] ?? 'world');
};

mnapoli added a commit to brefphp/aws-lambda-layers that referenced this issue Aug 23, 2024
mnapoli added a commit to brefphp/aws-lambda-layers that referenced this issue Aug 25, 2024
@mnapoli
Copy link
Member

mnapoli commented Aug 26, 2024

Fixed in the latest release.

@mnapoli mnapoli closed this as completed Aug 26, 2024
@davidsickmiller
Copy link

davidsickmiller commented Aug 29, 2024

I appreciate your addressing this error, as I recently encountered it myself. Upgrading to the latest version fixes this particular error for me.

However, I'm getting a new error a few steps later:

$gpg = new gnupg(['home_dir' => '/tmp']);
$info = $gpg->import('key goes here');
echo json_encode($info);    // Prints: false
echo $gpg->geterror();    // Prints: import failed
echo json_encode($gpg->geterrorinfo());  // Prints: {"generic_message":"import failed","gpgme_code":117440662,"gpgme_source":"GPGME","gpgme_message":"Invalid crypto engine"}

The same code works fine in Docker (FROM bref/php-82-fpm-dev:latest + COPY --from=bref/extra-gnupg-php-82:1 /opt /opt).

@mnapoli
Copy link
Member

mnapoli commented Aug 29, 2024

Hi David! Thanks for the report. It's a shame I don't know if the person that originally contributed this extension ever got it to work. I've never used the extension so I don't know where to start for a quick fix 😬

@mdschertz
Copy link
Author

mdschertz commented Aug 29, 2024 via email

@davidsickmiller
Copy link

I've organized a clean reproduction of the problem and created a separate issue for it: #556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants