我正在尝试进行XML签名验证。以下是Aadhaar无纸离线e教程https://uidai.gov.in/ecosystem/authentication-devices-documents/about-aadhaar-paperless-offline-e-kyc.html的链接
with open('/home/user/Downloads/uidai_auth_sign_prod_2023.cer', 'rb') as f:
key = f.read()
import xml.etree.ElementTree as ET
tree=ET.parse("/home/user/Downloads/offlineaadhaar202205040207.xml")
root = tree.getroot()
print(root)
try:
verified_data = XMLVerifier().verify(root, require_x509=False, x509_cert=key).signed_xml
print("Data is : %s" % verified_data)
except Exception as exce:
print(exce)此代码出现错误:
签名验证失败:无效填充
如果有任何其他解决方案来验证xml签名。请告诉我们。
发布于 2022-05-17 10:25:21
我发现XMLVerifier对验证签名的xml很有用。pip软件包需要安装
pip安装signxml
这是我的工作片段
码
from signxml import XMLVerifier
aadhar_file = '<path_to_signed_aadhaar_xml>'
cert = open('path_to_uidai_auth_sign_prod_2023.pem', "r+").read()
root = le.parse(aadhar_file).getroot()
try:
verify = XMLVerifier().verify(root, x509_cert=cert)
except Exception as e:
print(str(e))如果签名无效,这将引发异常。
InvalidDigest:摘要不匹配的引用0
注意:请使用有效证书(基于推荐的)来验证aadhaar xml。
https://stackoverflow.com/questions/72074524
复制相似问题