目前,我正在使用pyopenssl提取证书信息和验证链。但是,对于过期检查,我需要提取二进制/证书的签名时间。
在Linux环境中,有什么方法可以准确地提供这些信息吗?

发布于 2022-06-06 16:27:07
我同样需要获得pe_file (Windows二进制文件)被签名的时间。
我花了一段时间才弄明白如何使用signify和python来获取这些信息。他们的关键是弄清楚如何跟踪和使用signify文档中的图形,这里是:https://signify.readthedocs.io/en/latest/authenticode.html#pkcs7-objects
参见此示例:
from signify.authenticode.signed_pe import SignedPEFile
pathname = r"SoftwareUpdate.exe"
with open(pathname, "rb") as f:
pefile = SignedPEFile(f)
print(list(pefile.signed_datas)[0].signer_infos[0].countersigner.signing_time)我在Ubuntu上根据SoftwareUpdate.exe项目中的signify测试文件测试了这一点:
tools/Python$ curl -O https://raw.githubusercontent.com/ralphje/signify/master/tests/test_data/SoftwareUpdate.exe
tools/Python$ python3 get_pefile_signify_time.py
2008-07-25 22:21:53+00:00来自Windows的屏幕截图相同:

上面的片段在这里:time.py
这是我用来解决这个问题的脚本:signify.py
我在文件夹中有其他与pefile相关的示例。
相关:
https://stackoverflow.com/questions/34951975
复制相似问题