Save Ukraine

GnuPG with PHP

Christian Kruse,

For a spare time project I'm working on I wanted to send GPG encrypted and/or signed emails. Since I use PHP for this project, it seemed natural to use the GnuPG PECL.

After two evenings of work I'd like to try to summarize my experiences: first of all, error handling is very basic. You don't get very meaningful error messages (in fact, you don't get any error messages until you call gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING)…). Error messages like „get_key failed“ are not very obvious.

Also nice to know (and not obvious): you have to set the environment variable GNUPGHOME to the full path to your keyring files. E.g. if your keyring is stored in /var/www/, you have to specify the GNUPGHOME variable as follows: putenv("GNUPGHOME=/var/www/");

All in all, the API is usable but error handling seems very basic.