G'day fellow monks,

I've got a module I've written that's giving me quite a headache. When I run the CGI script that calls the module from the command line, it runs properly. When I try to call the CGI script from a web browser, I get the following error:

Software error: Cannot encrypt text: No known recipients for encryption For help, please send mail to the webmaster (root@localhost), giving t +his error message and the time and date of the error.

Here's the module I've written:

package TRIWeb::CCHandler; use strict; use Crypt::OpenPGP; our $VERSION = '$rev$'; our $PUBKEY = './trikey.pub'; sub new { my $class = shift; my $self = { cc_type => '', cc_number => '', cc_name => '', cc_expiry => '', cc_amount => 0, }; return bless $self, $class; } sub cc_set { my $self = shift; $self->{"cc_$_[0]"} = $_[1]; } sub ciphertext { my $self = shift; my $gpg = Crypt::OpenPGP->new or die "Cannot create Crypt::OpenPGP object: $!"; my $ring = Crypt::OpenPGP::KeyRing->new( Recipients => $PUBKEY ) or die "Cannot create keyring."; my $plaintext = <<"EOD"; ---------------------------------------- CC Type: $self->{cc_type} CC Number: $self->{cc_number} CC Name: $self->{cc_name} CC Expiry: $self->{cc_expiry} CC Amount: $self->{cc_amount} ---------------------------------------- EOD my $cipher = $gpg->encrypt( Compat => 'GnuPG', PubRing => $ring, Data => $plaintext, Armour => 1, Recipients => 'doug@tri' ) or die "Cannot encrypt text: " . $gpg->errstr; return $cipher; } 1;

And here's the portion of the CGI script that uses the module:

my $cc = new TRIWeb::CCHandler; $cc->cc_set( 'type', $form_vars{cc_type} ); $cc->cc_set( 'number', $form_vars{cc_number} ); + $cc->cc_set( 'name', $form_vars{cc_name} ); $cc->cc_set( 'expiry', $form_vars{exp_mo} . '/' . $form_vars{exp_yr} ) +; $cc->cc_set( 'amount', $form_vars{fee} ); $sth->execute( $form_vars{first_name}, $form_vars{last_name}, $form_va +rs{address_1}, $form_vars{address_2}, $form_vars{city}, $form_vars{pro +vince}, $form_vars{country}, $form_vars{postal_code}, $form_var +s{phone_work}, $form_vars{ext_work}, $form_vars{phone_work2}, $form_va +rs{ext_work2}, $form_vars{phone_home}, $form_vars{fax}, $form_vars{ema +il}, $form_vars{email2}, $cc->ciphertext ) ;

Any help would be greatly appreciated.

Thanks,


_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

In reply to Problem with module using Crypt::OpenPGP by DamnDirtyApe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.