Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PGP encrypt string from web form - "cannot open keyrings"

Status
Not open for further replies.

securityboy

Programmer
Dec 4, 2002
2
US
Hello -

I am trying my darndest to get a string PGP-encrypted.

Unfortunately, PGP keeps saying:
Code:
  Cannot open keyrings
  Encryption error
  Error: insufficient random bits

This is on a shared Unix host, where PGP 6.5.8 is being called from PHP 4 under Apache, which runs as user "nobody".

First I tried saving the cleartext to a temp file and just having PHP exec PGP (after setting PGPPATH) in order to create an encrypted temp file. Apparently user "nobody" can't do such things.

Next I tried having PHP pipe the cleartext string to the full encryption command (/home/me/pgp658/pgp -feat +batchmode my.key.id@me.com), but it returns NO output whatsoever. Now I've put the PGPPATH variable and the full command for PGP into a simple little two-line shell script, and then I used PHP to pipe the variable to this shell script.

This works 100% perfectly from the command line (SSH as myself) but running under Apache (as "nobody") it just gives me the error messages above, apparently indicating some kind of file permissions issue or something. I chmod'd the keyrings to 666... even put the secret keyring back in there for it to find, but it's still whining.

Does anyone, anywhere, ever PGP-encrypt a string while running as user "nobody"?? Any tips? Please?? What am I missing?

I am willing to switch PGP versions or use GPG, or whatever. Or, if anyone can give me a bit of Perl help I could presumably use cgiwrap and pass the cleartext string to my little shell script, which would in turn call PGP. I actually wish I could try that but I don't know any Perl. Do YOU? :)

Thanks very much. I appreciate YOU taking a moment to steer me in the right direction. I feel stupid for such a simple task taking me so long, but I look forward to hearing your input.

:b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top