1
0
Fork 0

- always encrypt if we have a key

git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@232 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
Jan Dittberner 2007-07-10 15:50:25 +00:00
parent b8c1b30e11
commit 732bb17fc5

View file

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