diff options
-rw-r--r-- | extensions/SecureMail/Extension.pm | 13 | ||||
-rw-r--r-- | extensions/SecureMail/template/en/default/hook/global/user-error-errors.html.tmpl | 4 |
2 files changed, 9 insertions, 8 deletions
diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm index ca5516c0a..97722d9ac 100644 --- a/extensions/SecureMail/Extension.pm +++ b/extensions/SecureMail/Extension.pm @@ -28,6 +28,7 @@ use Bugzilla::Object; use Bugzilla::User; use Bugzilla::Util qw(correct_urlbase trim trick_taint); use Bugzilla::Error; +use Crypt::OpenPGP::Armour; use Crypt::OpenPGP::KeyRing; use Crypt::OpenPGP; use Crypt::SMIME; @@ -86,10 +87,9 @@ sub object_validators { if ($value =~ /PUBLIC KEY/) { # PGP keys must be ASCII-armoured. - my $ring = new Crypt::OpenPGP::KeyRing(Data => $value); - $ring->read if $ring; - if (!defined $ring || !scalar $ring->blocks) { - ThrowUserError('securemail_invalid_key'); + if (!Crypt::OpenPGP::Armour->unarmour($value)) { + ThrowUserError('securemail_invalid_key', + { errstr => Crypt::OpenPGP::Armour->errstr }); } } elsif ($value =~ /BEGIN CERTIFICATE/) { @@ -100,12 +100,12 @@ sub object_validators { trick_taint($value); my $smime = Crypt::SMIME->new(); - eval { $smime->setPublicKey([$value]); }; if ($@) { - ThrowUserError('securemail_invalid_key'); + ThrowUserError('securemail_invalid_key', + { errstr => $@ }); } } else { @@ -276,6 +276,7 @@ sub _make_secure { Cipher => 'CAST5', Armour => 1); if (defined $encrypted) { + $email->encoding_set(''); $email->body_set($encrypted); } else { diff --git a/extensions/SecureMail/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/SecureMail/template/en/default/hook/global/user-error-errors.html.tmpl index f48a5389f..46b093674 100644 --- a/extensions/SecureMail/template/en/default/hook/global/user-error-errors.html.tmpl +++ b/extensions/SecureMail/template/en/default/hook/global/user-error-errors.html.tmpl @@ -23,5 +23,5 @@ that you are entering either an ASCII-armored PGP/GPG public key, including the "BEGIN PGP PUBLIC KEY BLOCK" and "END PGP PUBLIC KEY BLOCK" lines, or a PEM format (Base64-encoded X.509) S/MIME key, including the - BEGIN CERTIFICATE and END CERTIFICATE lines. -[% END %]
\ No newline at end of file + BEGIN CERTIFICATE and END CERTIFICATE lines.<br><br>[% errstr FILTER html %] +[% END %] |