We help IT Professionals succeed at work.

PHP interact with PGP(2.6.3i)

kidwong asked
I am a new user for PGP and PHP, I have installed the PGP 2.6.3i in my computer, running the Mandrake Linux 8.1. The PGP works fine for a single user, that me.

But recently, I need to have a IMAP mail server with PGP to encrypt the email for my friends and other family members through the Internet. I would like to implement it with PHP. However, my PHP program doesn't work for it. It seems that the user id through the PHP is "nobody" in the Linux server. But I don't know how to solve it. Does it need some configuration in PGP (e.g. config.txt)?Please give me a hand. Thank you.

Some of the setting of the Linux server:
PHP 4.0.6
Apache 1.3.20
PGP 2.6.3i
pgp binary in /usr/local/src/pgp
pgp public keyring: /root/.pgp/pubring.pgp
PHP program:
$pgp = "/usr/local/src/pgp";
$tmpdir = "/ramdisk/";

$randnum = rand(1, 10000000);

$infile = $tmpdir. "tmp-in.". $randnum;
$outfile = $tmpdir. "tmp-out.". $randnum;

$fd = fopen($infile, "w");
fputs($fd, $message);

$run = "$pgp -ae $infile (KeyID) -o $outfile";
if (file_exists($outfile)) {
    $fd = fopen($outfile, "r");
    $enoutput = fread($fd, filesize($outfile));
unlink ($infile);
unlink ($outfile);
Watch Question

nobody is the apache server.  We recently incorporated pgp and s/mime into IMP ( http://www.horde.org/imp ) for one of our customers ( http://www.medemail.com.au ).  The way we got around this was to write a wrapper app that would call gpg as a specific user and pass the parameters to gpg (or in your case pgp).

I'm not in a position to offer this code but if you like contact Del ( http://www.babel.com.au ) and I'm sure something could be sorted out.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.