Google Answers Logo
View Question
 
Q: GNUPG working with PHP and mail client ( No Answer,   1 Comment )
Question  
Subject: GNUPG working with PHP and mail client
Category: Computers > Security
Asked by: grumb-ga
List Price: $5.00
Posted: 24 Aug 2005 21:33 PDT
Expires: 23 Sep 2005 21:33 PDT
Question ID: 560106
Hi,
I use a php script to generate GPG encrypted email, which is sent to
my email address


--------------------------------------
$gpg = "/usr/bin/gpg";
$encrypt_command = "echo $message | $gpg --homedir /home/kbedso/.gnupg
--always-trust --no-secmem-warning -e -a -r 2515F7B7";
$encrypted=shell_exec("$encrypt_command");
$new=$encrypted;

$from="From: Name <myemailaddress@what.com>";


mail('myemailaddress@what.com','Your Encrypted Message',$new,$from); 
print $new;

-------------------------------------

when i open this in my mail program thunderbird, using the GPG
Enigmail plugin I get the following ( i use mac OSX)


-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.2.1 (GNU/Linux)

hQQOAyM4+jcgqEPfEBAAgieVwzpPMaW7JGr9TxZly3Pqc49qmnoB554xh71rZmRq
cHofXw57ir7Z+h1m42xOH+w2SAoRhGz6hDRw4bEVcaI/m9HBbcvHEJHGMh9R3GUF
WCiftdDgj5z165mjBJlp8HJLSojjo3L7gVvD94moGlZJa5g6zhapynVDjDLYW0uJ
PTsQwVQWfmEtdYG6iEuoPiumbuPlVsH2p3muINcbg/N0BYZ92ulv3/Wrp0XY90FR
IWy91Y/eDxaIwWlagvGm8X6f4v/5ZiyXDpu8pL4gs8GdICI35vCNC4t4OXXXwXoT
FsZF/MIwQuigKsGoqCfmig+/M/C1KpBbfRKazAyix3x5uL5MUhTjRmIOTkt0B+Xf
S8RvlzJzFdHWESjr1+Ye1Uqo/9UXh1awJdYXXmA6kxElzxNQ0XwO7/hNfM8se/H9
hrsXAzb6ZErDgj0oIxrH+Zw0iWeUotkLmusP+204PxRs1MtksdXkJMm1nlZzIohu
Af8y8a2Z7IQGQVgAEtSval7wIOqseHnOgO9YPEDqcQQJ27/uL9qy5s8RaPTdR4tG
yT9tqShPg0uDOB4kzDgXRWM0Pk1BGC2lxHt58NJ6KBv8/bnvZ+yE5S7eys/hFiZ3
OyzeIQ+GgYbLS3QsEagn+gKljPcbN3lktlKsjI6nQZfxWZbMwf6wUF+pb7iUHOAQ
AKN3KMUoG8xTLiesWiYBcKuZgbYtLleqa8la/SfUuNvWcT526n4AEWx2xAC+wocp
WHlwQthB7hcHuXN3GnpaQprktFENLOcnrV4uW8k47YKlisY1oCYstx2OcaRmNfwE
DZqrhfLMbClkLowul745udo0hqjztjXDjqN8PYPokvTctZzYhnixeWl7mVCb9nCW
SOaTExMU8DRlQgJXUbm85B6oc5KN3ilE9cOdpu+tZuNieVZPCySLqaq81mjFB/Ec
JEYioVLgZdHQv5Mc1fBaFl6L4qc0EBD3KeFOwxEtl3+mjOIX7TMQXgNC7bl1FCpJ
4FRFDJlqDYCYqHU02EXXyZnkr9zlrZ2b46CqD4XaqEAWC0c4YLyZmKayCn0Q+MZG
ROHiqhSLHewjxqM0TU0Mpuu0cQqKB+rIsGRyxZFTgExyfBy8wdTfXcvyJVZhxpns
VriNBiSr2qsueUALV7s38vc7pMtZ91dL6aK+sNamlUjLCjEOYQvS/puiJEDrmcoT
EkbUvzPnQjUlcfXeLVmyk+U9v/7LlExdgrmopFEThFrchaz1/qJh/N6H7Mq7Gd2N
wFBFbTRwqMr4AKoVNES2t2l0tUIQj1n3tgUO/PsM7stP5s95sMG0K81o9q6h4qJI
0UArSu7h5Fj5LVxopEfvVVYhnWRCTb0/ToNvey0KC6PU0jsBhVX+fqu5w74yG+0X
N7dzA1hG36NX2dnpBx1WtzRubBnaMsWNL9R6QD021DbdJYcDXvItCemBU2tGUA==
=iqv8
-----END PGP MESSAGE-----


When I click on decrypt the decrypt option,
It asks for my passphrase, which I enter--

then doesnt decrypt the message- 
and in the console gives the following message

enigmail> /usr/local/bin/gpg --charset utf8 --batch --no-tty --status-fd 2 -d -
-passphrase-fd 0 --no-use-agent 
gpg: encrypted with 4096-bit ELG-E key, ID 20A843DF, created 2005-08-22
"Kim (installing stuff is fun) <myemailadress>"
enigmail.js: Enigmail.decryptMessageEnd: Error in command execution

-------------------------------------------

I dont know what this error means, My mail program successfully
decrypts all other mail messages,
just not the ones I generate via php. any ideas on whats causing the problem?
Answer  
There is no answer at this time.

Comments  
Subject: Re: GNUPG working with PHP and mail client
From: techtonix-ga on 31 Aug 2005 02:25 PDT
 
The proper way to feed command through a pipe is to use
http://www.php.net/popen command. This way you will avoid possible
limitations of echo and text, contained in your $message. For example
you message can be "Hello, | clear |" and in your case you can get
something like:

echo Hello, | clear | /usr/bin/gpg --homedir /home/kbedso/.gnupg
--always-trust --no-secmem-warning -e -a -r 2515F7B7

The possible solution can be:
--------------------------------------
$gpg = "/usr/bin/gpg";

$handle = popen("$gpg --homedir /home/kbedso/.gnupg
--always-trust --no-secmem-warning -e -a -r 2515F7B7", 'w');
$sentbytes = fwrite($handle, 2096);
echo "$sentbytes written on the pipe";
pclose($handle);
--------------------------------------

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy