diff options
author | Ruben Pollan <meskio@sindominio.net> | 2014-10-09 10:47:30 -0500 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2014-10-09 10:47:30 -0500 |
commit | 2c7c18b04d0435de65b58d57f22e229577189ca2 (patch) | |
tree | 89ffec3d4181eee3942a2ca0b7eeb1e0341cf971 /src/leap/keymanager/openpgp.py | |
parent | 55b6d38c14fd5fbbc2a56e4edec7a8715cc3253d (diff) | |
parent | 8f01d6b818a36014e21a13baaf6c5112ef9e9a35 (diff) |
Merge branch 'drebs/bug/6022_fix-call-to-verify-file' into develop
Diffstat (limited to 'src/leap/keymanager/openpgp.py')
-rw-r--r-- | src/leap/keymanager/openpgp.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/leap/keymanager/openpgp.py b/src/leap/keymanager/openpgp.py index 46ae2aa..ee37a34 100644 --- a/src/leap/keymanager/openpgp.py +++ b/src/leap/keymanager/openpgp.py @@ -22,12 +22,11 @@ import os import re import shutil import tempfile +import io -from contextlib import closing from gnupg import GPG from gnupg.gnupg import GPGUtilities -from gnupg._util import _make_binary_stream from leap.common.check import leap_assert, leap_assert_type, leap_check from leap.keymanager import errors @@ -649,17 +648,13 @@ class OpenPGPScheme(EncryptionScheme): result = gpg.verify(data) else: # to verify using a detached sig we have to use - # gpg.verify_file(), which receives the name of - # files containing the date and the signature. + # gpg.verify_file(), which receives the data as a binary + # stream and the name of a file containing the signature. sf, sfname = tempfile.mkstemp() with os.fdopen(sf, 'w') as sfd: sfd.write(detached_sig) - df, dfname = tempfile.mkstemp() - with os.fdopen(df, 'w') as sdd: - sdd.write(data) - result = gpg.verify_file(dfname, sig_file=sfname) + result = gpg.verify_file(io.BytesIO(data), sig_file=sfname) os.unlink(sfname) - os.unlink(dfname) gpgpubkey = gpg.list_keys().pop() valid = result.valid rfprint = result.fingerprint |