[PHP] Re: Decrypting data with GnuPG
Just for the record, adding the --batch argument to the GnuPG command solved the problem. Regards, Pierre-Luc Pierre-Luc Soucy wrote: Hi, I would like to decrypt data encoded with GnuPG without including the private key passphrase in the command to prevent people from viewing it with ps. Here is the code I wrote: $command = /usr/bin/gpg --homedir=/path/to/.gnupg --no-secmem-warning --always-trust --yes --output /path/to/output.txt --decrypt /path/to/testtext.asc; $passphrase = '***'; $fp = popen($command, 'w+'); fputs($fp, $passphrase); pclose($fp); print Done; exit; == I assumed that the fputs() function would write the passphrase at the prompt, but that doesn't seem to be the case - the command does not create the output.txt file when ran by the PHP program (which is running as a CGI under my user BTW) while it works when ran from the shell. Any idea why? Thanks! Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Decrypting data with GnuPG
From the GnuPG docs: --passphrase-fd n Read the passphrase from file descriptor n. If you use 0 for n, the passphrase will be read from stdin. This can only be used if only one passphrase is supplied. Don't use this option if you can avoid it. I added --passphrase-fd 0 to my command so the passphrase should normally be read from stdin (according to the docs), but it still does not work. Any idea? I am unfortunately not familiar with C code, so I can difficultly find solutions to my problems by reading the GnuPG source. Thanks! Pierre-Luc Evan Nemerson wrote: GnuPG doesn't use stdin to read the password, which is where you're sending it. It uses a more low-level interface (check out the below link if you're interested) where they interact directly with the virtual console. Try piping to your command- that won't work either echo $PASSPHRASE | \ /usr/bin/gpg \ --homedir=/path/to/.gnupg \ --no-secmem-warning \ --always-trust \ --yes \ --output /path/to/output.txt \ --decrypt /path/to/testtext.asc GnuPG source code for TTY I/O: http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/*checkout*/gnupg/util/ttyio.c?rev=1.28content-type=text/plain On Wed, 2003-05-28 at 16:14, Pierre-Luc Soucy wrote: Hi, I would like to decrypt data encoded with GnuPG without including the private key passphrase in the command to prevent people from viewing it with ps. Here is the code I wrote: $command = /usr/bin/gpg --homedir=/path/to/.gnupg --no-secmem-warning --always-trust --yes --output /path/to/output.txt --decrypt /path/to/testtext.asc; $passphrase = '***'; $fp = popen($command, 'w+'); fputs($fp, $passphrase); pclose($fp); print Done; exit; == I assumed that the fputs() function would write the passphrase at the prompt, but that doesn't seem to be the case - the command does not create the output.txt file when ran by the PHP program (which is running as a CGI under my user BTW) while it works when ran from the shell. Any idea why? Thanks! Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Decrypting data with GnuPG
I just tried, but that didn't correct the problem - the output.txt file is still not generated: ? $command = /usr/bin/gpg --homedir=/path/to/homedir/.gnupg --no-secmem-warning --passphrase-fd 0 --always-trust --yes --output /path/to/homedir/.gpgkeys/temp/output.txt --decrypt /path/to/homedir/.gpgkeys/temp/testtext.asc; $passphrase = 'MY_PASSPHRASE'.\n; $fp = popen($command, 'w+'); fputs($fp, $passphrase); fputs($fp, $passphrase); pclose($fp); print Done; exit; ? Regards, Pierre-Luc Evan Nemerson wrote: Are you appending a newline to your passphrase? $passphrase = my gnupg passphrase\n; On Thursday 29 May 2003 06:56 am, you wrote: From the GnuPG docs: --passphrase-fd n Read the passphrase from file descriptor n. If you use 0 for n, the passphrase will be read from stdin. This can only be used if only one passphrase is supplied. Don't use this option if you can avoid it. I added --passphrase-fd 0 to my command so the passphrase should normally be read from stdin (according to the docs), but it still does not work. Any idea? I am unfortunately not familiar with C code, so I can difficultly find solutions to my problems by reading the GnuPG source. Thanks! Pierre-Luc Evan Nemerson wrote: GnuPG doesn't use stdin to read the password, which is where you're sending it. It uses a more low-level interface (check out the below link if you're interested) where they interact directly with the virtual console. Try piping to your command- that won't work either echo $PASSPHRASE | \ /usr/bin/gpg \ --homedir=/path/to/.gnupg \ --no-secmem-warning \ --always-trust \ --yes \ --output /path/to/output.txt \ --decrypt /path/to/testtext.asc GnuPG source code for TTY I/O: http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/*checkout*/gnupg/util/ttyio.c?re v=1.28content-type=text/plain On Wed, 2003-05-28 at 16:14, Pierre-Luc Soucy wrote: Hi, I would like to decrypt data encoded with GnuPG without including the private key passphrase in the command to prevent people from viewing it with ps. Here is the code I wrote: $command = /usr/bin/gpg --homedir=/path/to/.gnupg --no-secmem-warning --always-trust --yes --output /path/to/output.txt --decrypt /path/to/testtext.asc; $passphrase = '***'; $fp = popen($command, 'w+'); fputs($fp, $passphrase); pclose($fp); print Done; exit; == I assumed that the fputs() function would write the passphrase at the prompt, but that doesn't seem to be the case - the command does not create the output.txt file when ran by the PHP program (which is running as a CGI under my user BTW) while it works when ran from the shell. Any idea why? Thanks! Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Decrypting data with GnuPG
Hi, I would like to decrypt data encoded with GnuPG without including the private key passphrase in the command to prevent people from viewing it with ps. Here is the code I wrote: $command = /usr/bin/gpg --homedir=/path/to/.gnupg --no-secmem-warning --always-trust --yes --output /path/to/output.txt --decrypt /path/to/testtext.asc; $passphrase = '***'; $fp = popen($command, 'w+'); fputs($fp, $passphrase); pclose($fp); print Done; exit; == I assumed that the fputs() function would write the passphrase at the prompt, but that doesn't seem to be the case - the command does not create the output.txt file when ran by the PHP program (which is running as a CGI under my user BTW) while it works when ran from the shell. Any idea why? Thanks! Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Decrypting data with GnuPG
Hi, Does that mean that there is no way to achieve this with PHP and that I should rather use the --passphrase-fd argument? Thanks, Pierre-Luc Evan Nemerson wrote: GnuPG doesn't use stdin to read the password, which is where you're sending it. It uses a more low-level interface (check out the below link if you're interested) where they interact directly with the virtual console. Try piping to your command- that won't work either echo $PASSPHRASE | \ /usr/bin/gpg \ --homedir=/path/to/.gnupg \ --no-secmem-warning \ --always-trust \ --yes \ --output /path/to/output.txt \ --decrypt /path/to/testtext.asc GnuPG source code for TTY I/O: http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/*checkout*/gnupg/util/ttyio.c?rev=1.28content-type=text/plain On Wed, 2003-05-28 at 16:14, Pierre-Luc Soucy wrote: Hi, I would like to decrypt data encoded with GnuPG without including the private key passphrase in the command to prevent people from viewing it with ps. Here is the code I wrote: $command = /usr/bin/gpg --homedir=/path/to/.gnupg --no-secmem-warning --always-trust --yes --output /path/to/output.txt --decrypt /path/to/testtext.asc; $passphrase = '***'; $fp = popen($command, 'w+'); fputs($fp, $passphrase); pclose($fp); print Done; exit; == I assumed that the fputs() function would write the passphrase at the prompt, but that doesn't seem to be the case - the command does not create the output.txt file when ran by the PHP program (which is running as a CGI under my user BTW) while it works when ran from the shell. Any idea why? Thanks! Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP OpenSSL question
Hi, I have loaded the appropriate keys: //load keys $ca_file = openssl_x509_read('file://'.$ca_file); $public_key = openssl_pkey_get_public('file://'.$public_key_file); $private_key = openssl_pkey_get_private('file://'.$private_key_file); and can successfully encrypt data: $to_send = '?xml version=1.0 encoding=UTF-8 standalone=no? epp xmlns=urn:ietf:params:xml:ns:epp-1.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd hello/ /epp'; openssl_public_encrypt($to_send, $message, $public_key); I then write the encrypted data to the socket using socket_write (when communicating with a server) but the server disconnects me when I attempt to read its output with socket_read: Warning: socket_read() unable to read from socket [54]: Connection reset by peer Any idea why? To what I understand, I might need to do a SSL handshake first? How can that be done with PHP? Thanks a lot! Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Stream does not support seeking
Hi, We have recently upgraded to PHP 4.30 and since then, some people on our server started getting the following error message on their sites: Warning: main() [function.main]: stream does not support seeking in http://www.domain.com/path/to/file.inc on line 0 We have found that it happens when people use URLs in the include function, but have no idea why, espcially since allow_url_fopen is on. Any suggestions? Thanks, Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Editors
Do you know any good equivalent with similar features for Linux? Thanks, Pierre-Luc Soucy PHPEdit i use it personally www.phpedit.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with make test
Hi, I just configured and make'd PHP with no problem, but when I run make test, I get the following output: - = CWD : /home/programs/php/php-4.3.0 PHP : /home/programs/php/php-4.3.0/sapi/cli/php PHP_SAPI: cli PHP_VERSION : 4.3.0 ZEND_VERSION: 1.3.0 PHP_OS : Linux INI actual : /usr/local/Zend/etc/php.ini More .INIs : Fatal error: Nesting level too deep - recursive dependency? in Unknown on line 0 Extra dirs : = TIME START 2003-01-06 13:27:47 = FAIL EXPECT [tests/run-test/test001.phpt] FAIL EXPECTF [tests/run-test/test002.phpt] FAIL EXPECTREGEX [tests/run-test/test003.phpt] FAIL INI section allows '=' [tests/run-test/test004.phpt] FAIL Error message handling [tests/run-test/test005.phpt] PASS Error messages are shown [tests/run-test/test006.phpt] FAIL dirname test [tests/run-test/test007.phpt] FAIL Trivial Hello World test [tests/basic/001.phpt] SKIP Simple POST Method test [tests/basic/002.phpt] (reason: Fatal error: Nesting level too deep - recursive dependency? in Unknown on line 0) SKIP GET and POST Method combined [tests/basic/003.phpt] (reason: Fatal error: Nesting level too deep - recursive dependency? in Unknown on line 0) SKIP Two variables in POST data [tests/basic/004.phpt] (reason: Fatal error: Nesting level too deep - recursive dependency? in Unknown on line 0) SKIP Three variables in POST data [tests/basic/005.phpt] (reason: Fatal error: Nesting level too deep - recursive dependency? in Unknown on line 0) FAIL Add 3 variables together and print result [tests/basic/006.phpt] FAIL Multiply 3 variables and print result [tests/basic/007.phpt] FAIL Divide 3 variables and print result [tests/basic/008.phpt] FAIL Subtract 3 variables and print result [tests/basic/009.phpt] FAIL Testing | and operators [tests/basic/010.phpt] SKIP Testing $argc and $argv handling (GET) [tests/basic/011.phpt] (reason: Fatal error: Nesting level too deep - recursive dependency? in Unknown on line 0) FAIL Testing $argc and $argv handling (cli) [tests/basic/012.phpt] FAIL Bug #20539 (PHP CLI Segmentation Fault) [tests/basic/bug20539.phpt] FAIL Methods via variable name, bug #20120 [tests/classes/bug20120.phpt] FAIL Classes general test [tests/classes/class_example.phpt] FAIL Classes inheritance test [tests/classes/inheritance.phpt] FAIL Strlen() function test [tests/func/001.phpt] FAIL Static variables in functions [tests/func/002.phpt] FAIL General function test [tests/func/003.phpt] FAIL General function test [tests/func/004.phpt] FAIL Testing register_shutdown_function() [tests/func/005.phpt] FAIL Output buffering tests [tests/func/006.phpt] FAIL INI functions test [tests/func/007.phpt] FAIL Test for buffering in core functions with implicit flush off [tests/func/008.phpt] FAIL Test for buffering in core functions with implicit flush on [tests/func/009.phpt] FAIL Simple If condition test [tests/lang/001.phpt] FAIL Simple While Loop Test [tests/lang/002.phpt] FAIL Simple Switch Test [tests/lang/003.phpt] FAIL Simple If/Else Test [tests/lang/004.phpt] FAIL Simple If/ElseIf/Else Test [tests/lang/005.phpt] FAIL Nested If/ElseIf/Else Test [tests/lang/006.phpt] FAIL Function call with global and static variables [tests/lang/007.phpt] FAIL Testing recursive function [tests/lang/008.phpt] FAIL Testing function parameter passing [tests/lang/009.phpt] FAIL Testing function parameter passing with a return value [tests/lang/010.phpt] FAIL Testing nested functions [tests/lang/011.phpt] FAIL Testing stack after early function return [tests/lang/012.phpt] FAIL Testing eval function [tests/lang/013.phpt] FAIL Testing eval function inside user-defined function [tests/lang/014.phpt] FAIL Testing include [tests/lang/015.phpt] FAIL Testing user-defined function in included file [tests/lang/016.phpt] FAIL Testing user-defined function falling out of an If into another [tests/lang/017.phpt] FAIL eval() test [tests/lang/018.phpt] FAIL eval() test [tests/lang/019.phpt] FAIL Switch test 1 [tests/lang/020.phpt] FAIL Switch test 2 [tests/lang/021.phpt] FAIL Switch test 3 [tests/lang/022.phpt] FAIL Regression test [tests/lang/023.phpt] FAIL Looped regression test (may take a while) [tests/lang/024.phpt] - What does that mean? What do I need to do to fix that? Thanks, Pierre-Luc Soucy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php