NONparametrics

geekdom without assumption
NONparametrics

GnuPG, PHP, and Ubuntu

One of our upcoming projects at work is killing our old session management in favor of a RESTful Authentication and Authorization application to serve our Service Oriented Architecture framework (a mouthful, isn’t it?). A key piece of this authentication server relies on a single cookie that contains signed data. Given our bent toward open source–among other things–Gnu Privacy Guard seemed a natural choice for the encryption. We already make use of Mcrypt for storing sensitive information in our database, but that doesn’t seem to have a certificate handling and signing facility.

Unfortunately, there isn’t a maintained php5-gpg package for Ubuntu, so we turned to pecl (php extention community library). Building the module was pretty straightforward once I figured out the names of the Ubuntu packages that it depended on. So in three easy steps, here it is:

1) Install pear, php5 development library, and the gpgme library:
sudo apt-get update && sudo apt-get install php-pear php5-dev libgpgme11-dev

2) Use pear to build and install the extention:
sudo pecl install gnupg

3) Load the extension by creating

/etc/php5/apache2/conf.d/gnupg.ini

with one line:

extension=gnupg.so

…and restart apache:
sudo apache2ctrl graceful

Add some key files, and off you go.

Related Tags: [ , , , , ]

2 Responses to “GnuPG, PHP, and Ubuntu”

  1. Prashant says:

    Your article is helpful, but I am not getting this line “Add some key files, and off you go.” How should I generate key files? And what I need to do to run simpole gnupg example which is given on php.net http://www.php.net/manual/en/function.gnupg-encrypt.php ? Please help, thanks.

  2. swapnil says:

    Hi,

    I need assistance to load GPG/PGP libraries on Ubuntu server 12.04.

    I have installed all required libraries on this server.
    – gnupg
    – libgpg-error
    – gpgme
    I checked in phpinfo and got the result for gnupg. but I am quit confusing about, are these libraries are loaded properly or not?. when I execute the
    below code :

    this code gives me fatal error for class not found.

    Could you please assist me on this?

    Thanks,
    Swapnil

Leave a Reply