Merge pull request #1969 from devnull-/GPG_sign_option

Add a option to sign GPG emails
pull/2883/head
Andras Iklody 2018-01-24 11:11:03 +01:00 committed by GitHub
commit 173496c305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -44,7 +44,8 @@ $config = array(
'email' => '',
'homedir' => '',
'password' => '',
'bodyonlyencrypted' => false,
'bodyonlyencrypted' => false,
'sign' => true,
),
'SMIME' =>
array(

View File

@ -835,7 +835,15 @@ class Server extends AppModel {
'errorMessage' => '',
'test' => 'testBool',
'type' => 'boolean',
),
),
'sign' => array(
'level' => 2,
'description' => 'Enable the signing of GPG emails. By default, GPG emails are signed',
'value' => 'true',
'errorMessage' => '',
'test' => 'testBool',
'type' => 'boolean',
),
'email' => array(
'level' => 0,
'description' => 'The e-mail address that the instance\'s PGP key is tied to.',

View File

@ -724,8 +724,10 @@ class User extends AppModel {
require_once 'Crypt/GPG.php';
try {
$gpg = new Crypt_GPG(array('homedir' => Configure::read('GnuPG.homedir'), 'binary' => (Configure::read('GnuPG.binary') ? Configure::read('GnuPG.binary') : '/usr/bin/gpg'), 'debug')); // , 'debug' => true
$gpg->addSignKey(Configure::read('GnuPG.email'), Configure::read('GnuPG.password'));
$body = $gpg->sign($body, Crypt_GPG::SIGN_MODE_CLEAR);
if (Configure::read('GnuPG.sign')) {
$gpg->addSignKey(Configure::read('GnuPG.email'), Configure::read('GnuPG.password'));
$body = $gpg->sign($body, Crypt_GPG::SIGN_MODE_CLEAR);
}
} catch (Exception $e) {
$failureReason = " the message could not be signed. The following error message was returned by gpg: " . $e->getMessage();
$this->log($e->getMessage());