def envrcpt(self, to, *s): toName, toAddr = parseaddr(to) self.gpgm_pk = self.gpgm_get_public_key_fingerprint(toAddr) if self.gpgm_pk is not None: self.conf.log("Have private key for {}:\n{}".format(toAddr, self.gpgm_pk)) else: self.conf.log("No private key for {}.".format(toAddr)) return Milter.CONTINUE
def gpgm_get_public_key_fingerprint(self, addr): for k in self.gpgm_gpg.list_keys(): for uid in k['uids']: name, caddr = parseaddr(uid) canonical_curr = self.gpgm_canonical_email_address(caddr) canonical_search = self.gpgm_canonical_email_address(addr) if canonical_curr == canonical_search: self.conf.log("Found fingerprint") return k['fingerprint'] return ""
def header(self, name, val): lname = name.lower() if lname == 'dkim-signature': if (milterconfig.get('Syslog') and milterconfig.get('debugLevel') >= 1): syslog.syslog("{0}: {1}".format(name, val)) self.has_dkim += 1 if lname == 'from': fname, self.author = parseaddr(val) try: self.fdomain = self.author.split('@')[1] except IndexError as er: self.fdomain = '' # self.author was not a proper email address if (milterconfig.get('Syslog') and milterconfig.get('debugLevel') >= 1): syslog.syslog("{0}: {1}".format(name, val)) elif lname == 'authentication-results': self.arheaders.append(val) if self.fp: self.fp.write(b"%s: %s\n" % (name.encode("utf-8"), val.encode("utf-8"))) return Milter.CONTINUE