control: tag -1 -patch Hello Daniel,
On Thu 21 Nov 2019 at 02:30PM +08, Daniel Kahn Gillmor wrote: > diff --git a/email-print-mime-structure b/email-print-mime-structure > index ab90976..069648a 100755 > --- a/email-print-mime-structure > +++ b/email-print-mime-structure > @@ -135,6 +137,27 @@ class MimePrinter(object): > pass > return None > > + def openssl_decrypt(self, keys:List[str], ciphertext:bytes) -> > Optional[Message]: > + keyname:str > + ret:Optional[Message] = None > + for keyname in keys: > + inp:int > + outp:int > + inp, outp = os.pipe() > + with open(outp, 'wb') as outf: > + outf.write(ciphertext) > + cmd = ['openssl', 'smime', '-decrypt', '-inform', 'DER', > '-inkey', keyname] > + try: > + out:subprocess.CompletedProcess[bytes] = subprocess.run(cmd, > + > stdin=inp, > + > capture_output=True) > + except Exception as e: > + logging.warning(f'Failed to decrypt with openssl: {e}') > + return None > + if out.returncode == 0: > + return email.message_from_bytes(out.stdout) > + return None > + Again, this function is almost identical to gpg_decrypt, so please refactor. -- Sean Whitton
signature.asc
Description: PGP signature