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