diff --git a/gnuviechadmin/backend/BackendEntity.py b/gnuviechadmin/backend/BackendEntity.py index 06a02e4..291f625 100644 --- a/gnuviechadmin/backend/BackendEntity.py +++ b/gnuviechadmin/backend/BackendEntity.py @@ -71,8 +71,9 @@ class BackendEntity(object): and signs it usign GnuPG. If a public key of the recipient is available the mail is encrypted.""" plain = core.Data(text) - sig = core.Data() + cipher = core.Data() c = core.Context() + c.set_armor(1) signer = config.get('common', 'mailfrom') rcpt = config.get('common', 'mailto') c.signers_clear() @@ -83,7 +84,7 @@ class BackendEntity(object): raise Exception("No secret keys for signing available for %s." % ( signer)) keylist = [] - for key in [x for x in c.op_keylist_all(rcpt, 1)]: + for key in c.op_keylist_all(rcpt, 0): valid = 0 subkey = key.subkeys while subkey: @@ -96,13 +97,12 @@ class BackendEntity(object): if valid: keylist.append(key) if keylist: - c.set_armor(1) - c.op_encrypt_sign(keylist, 1, plain, sig) + c.op_encrypt_sign(keylist, 1, plain, cipher) else: - c.op_sign(plain, sig, mode.CLEAR) - sig.seek(0,0) + c.op_sign(plain, cipher, mode.CLEAR) + cipher.seek(0,0) - msg = MIMEText(sig.read()) + msg = MIMEText(cipher.read()) msg['Subject'] = subject msg['From'] = signer msg['To'] = rcpt