Hello,
Hello,
- as I receive the email I created in python, the signature is a separated file, but as I try to decrypt or verify the signature, the decryptor says “no data” although encrypted attachements are correctly decryptable
as the signature is “detached” and added to the mail as an attacement, it appears outlook plugin does not automaticaly take the email source as data, it really looks like a bug
can someone enlight me on this ?
thanks
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJXhP4dAA*************************************
*************************************************************ammnUKk/I
=dQk4
-----END PGP SIGNATURE-----
for information, here is the code I use to generate the email:
def encrypt(self,text):
gpg = gnupg.GPG()
encrypted_data = gpg.encrypt(text, ‘myemail@…’)
encrypted_string = str(encrypted_data)
if encrypted_data.ok:
return encrypted_string
else:
print 'status: ', encrypted_data.status
print 'stderr: ', encrypted_data.stderr
return None
def createSignature(self,msg):
text = re.sub(r’\r?\n’, ‘\r\n’, msg.as_string())
gpg = gnupg.GPG()
signature = gpg.sign(text,detach=True,passphrase=“***************”)
sig = MIMEText(‘’)
sig.set_type(‘application/pgp-signature’)
sig.set_charset(None)
sig.set_param(‘name’, ‘signature.asc’)
sig.add_header(‘Content-Description’, ‘OpenPGP digital signature’)
sig.add_header(‘Content-Disposition’,‘attachment’, filename=‘signature.asc’)
sig.set_payload(str(signature))
return sig
def send(self,destinations=):
payload = MIMEMultipart()
payload.set_param('protocol', 'application/pgp-signature')
payload.set_param('micalg', 'pgp-sha256') ####!!! GET THIS FROM KEY!
payload.preamble = 'This is an OpenPGP/MIME signed message.'
payload['From'] = "from@email"
payload['To'] = COMMASPACE.join(destinations)
payload['Date'] = formatdate(localtime = True)
payload['Subject'] = Header(self.subject, "utf-8")
mail_text=MIMEText(mail_text+"\n", 'html', "utf-8")
payload.attach(mail_text)
# signature
signature = self.createSignature(payload)
payload.attach(signature)
encrypted_mail=payload.as_string()
# send mail
smtp = smtplib.SMTP("localhost", 25)
smtp.set_debuglevel(True)
smtp.sendmail(payload['From'], destinations, encrypted_mail)
smtp.quit()