User Contributed Notes 6 notes

After spending some time trying to get this extension to work, I've found that you have to have the GNUPGHOME environment variable set so that the keychain can be found, and have it set equal to the .gnupg directory itself, not the apache/httpd user's home directory (which is what is shown in dan's example code). below is an example of this and a simple function I was working on at the time to encrypt a piece of data for storage in a database.

<?php// set the environment so gnupg can find the keyringputenv("GNUPGHOME=/home/apache/.gnupg");

I found that the apache or httpd user (or whichever user the webserver is using to run) needed to have write access to the .gnupg directory for the gnupg_php functions to work. This could be your problem. It seems a rather unsatisfactory feature of this module - gnupg keeps giving warnings that it is unsafe.

Very nice function, yet I cant seem to get it to work correctly. Here is what I have..

/** * Test Values. Will be grabbed from database. */$_STR_recipientKeyId='78F21BCA81042C23';

// This is a wrapper class I made that engulfs the gnupg classif(!class_exists('core_Gnupg')){ require(CORE_PATH_CLASS.'Gnupg.class.php');}

//$_OBJ_gpg is just an instantiation of that class. //returnInfo takes in the userID name, and uses the keyinfo() //function to return an array of data for that user.$_ARR_keyinfo=$_OBJ_gpg->returnInfo($_STR_recipientUserId);

//now I have the fully functional userid//ex: Jonathan Kushner <jkushner@livemercial.com>$_STR_recipientUserId=$_ARR_keyinfo[0]['uids'][0]['uid'];

###########################

See, originally I was using the fingerprint from the $_ARR_keyinfo above and passing that into the encrypt function, but it still associated the encrypted data with my personal private key that I have associated with apache.