使用JavaScript提取带数字签名PDF中的RFC 3161时间戳
提取PDF签名时间时无法找到signingTime对应的OID
我尝试从PDF文档中提取签名时间,通过Adobe Acrobat确认该文档包含时间戳,但打印已认证属性(authenticated attributes)时,无法找到signingTime对应的OID(1.2.840.113549.1.9.5)。
以下是我用于查找signingTime属性的代码:
// Extract all authenticated attributes const authenticatedAttributes = attrs.map(attribute => { const oid = forge.asn1.derToOid(attribute.value[0].value); const attributeName = forge.pki.oids[oid] || oid; // Try to resolve OID to a human-readable name // Extract the value, which might be a date, a string, or another encoded type let value; try { value = forge.util.bytesToUtf8(attribute.value[1].value[0].value); } catch (e) { value = forge.util.bytesToHex(attribute.value[1].value[0].value); } return { oid, name: attributeName, value, }; }); console.log("Authenticated Attributes:", authenticatedAttributes);
控制台输出的已认证属性中无signingTime的OID,尽管Acrobat签名详情显示其存在。
我的完整数据提取步骤代码如下:
const verify = (signature, signedData, signatureMeta) => { const message = getMessageFromSignature(signature); const { certificates, rawCapture: { signature: sig, authenticatedAttributes: attrs, digestAlgorithm, }, } = message; // console.log(attrs); // Extract all authenticated attributes const authenticatedAttributes = attrs.map(attribute => { const oid = forge.asn1.derToOid(attribute.value[0].value); const attributeName = forge.pki.oids[oid] || oid; // Try to resolve OID to a human-readable name // Extract the value, which might be a date, a string, or another encoded type let value; try { value = forge.util.bytesToUtf8(attribute.value[1].value[0].value); } catch (e) { value = forge.util.bytesToHex(attribute.value[1].value[0].value); } return { oid, name: attributeName, value, }; }); console.log("Authenticated Attributes:", authenticatedAttributes); };
我查阅了多个类似问题及数字签名相关文档,但均未解决问题。
针对mkl方案的更新(2024/08/31):
打印未签名属性(unsigned attributes)后,找到了OID 1.2.840.113549.1.9.16.2.14,但该OID无对应值。
针对mkl方案的二次更新(2024/09/15):
修改代码后,OID 1.2.840.113549.1.9.16.2.14的对应值为另一个OID,仍无法提取出Adobe显示的签名时间,恳请技术帮助。
内容的提问来源于stack exchange,提问作者faisalrasbihan
相关产品推荐
相关产品推荐

