PDA

View Full Version : Getting PGP to work with PHP


prime
05-03-2001, 04:54 PM
Hello!

I'm using a PHP page to dynamically generate an e-mail message. The e-mail message needs to be PGP encrypted before it is sent.

I initially thought this would be no problem, however PGP Safe Mode seems to prevent direct calls to pgpe (via Execute()). I was then hoping that popen() would work, like $pp = popen("pgpe ....", w); but I don't get any results from that either. I've tested the commands on the command line and they work fine.

Has anyone else got this working on FQ? What about using the PHP binary somehow?

Suggestions would be most appreciated :)

Thanks!

_Jeff

Terra
05-03-2001, 07:07 PM
You will need to go the CGI route with either perl or PHP in order to call external programs...

The reasons have been recently discussed in other relevant threads...

--
Terra
sysAdmin
FutureQuest

prime
05-05-2001, 12:18 AM
I figured out a workaround. For reference:

1. my pgp page writes the contents of the e-mail to be sent to a file
2. using Virtual() it then includes a php .cgi script that calls pgpe to do the encryption on the previously saved file
3. the main php page then continues execution, loads up the encrypted file, and mails it.

As far as I could tell, this should have been unnecessary - popen()[nbsp][nbsp]should have done the trick, but all I could find on the web was one person saying it was PGP that was the problem, not a problem with popen() being restricted by safe mode - but who knows? That was the most frustrating part - you don't get any error messages back when you try to execute something that safe mode blocks, you just get nothing. You're then left wondering if what you are trying to do is blocked, or if you have some sort of other error going that you can't even see (security, configuration, etc).

I also spent some time trying to figure out how to send HTML formatted mail that has been PGP encoded. The message has to be sent as text (MIME type text/plain) so the PGP encoding comes out all right, but then once it has been decrypted the mail client, it doesn't know that it's got HTML to display, and thus one sees the tags everywhere. Sending it is an encrypted attachment would probably work, however I was looking for a solution that would result as the e-mail being displayed as HTML instead of having to open the attachment in a browser. If anyone has any ideas...

_Jeff

Terra
05-05-2001, 12:50 AM
Please view:
http://www.aota.net/ubb/Forum15/HTML/000686-1.html

This will solve your error reporting problem...

However, the generated errors should still be in your log files:
logs_web/error
and/or
logs_cgi/php_error

not a problem with popen() being restricted by safe mode popen() cannot execute the pgp binary to perform the task, hence the problem found...[nbsp][nbsp]This does not take into account that popen()+pgpe may have their own separate issues beyond safe_mode denial...

Over the weekend - I am hoping to rollout a new PHP 4.0.5 which contains:
libmcrypt and mhash

This should help to solve lack of convenient encryption methods...

--
Terra
sysAdmin
FutureQuest

prime
05-05-2001, 01:20 AM
Thanks Terra - I did find the way to turn on the errors in the .htaccess. Unfortunately, the safe mode violations do not issue any errors (at least that PHP handles). It can be quite frustrating.

There is also a problem with my error logs - nothing ends up in them. I've checked the two you've mentioned and more - and they are empty. I was testing using SSL with a private SSL cert, so perhaps this is something to do with that? (this is on sacredpower.com)

You are right - popen() is crippled when used with the PHP module.

_Jeff

marty1101
07-23-2001, 05:06 PM
Where is .htaccess ?

I just made a file called htaccess under my www/, put "php_flag display_errors On" in it, but it still doesn't show error messages.

prime
07-23-2001, 05:19 PM
Make sure it is ".htaccess" with the period in front. That should do it 8}

marty1101
07-23-2001, 05:25 PM
Thanks. It's working now. I didn't run the right script that has errors. Now I can debug fast!