|
@@ -95,15 +95,18 @@ class CPDFWorker {
|
|
|
return error
|
|
|
})
|
|
|
|
|
|
- messageHandler.on('InitDocument', () => {
|
|
|
- const doc = Module._InitDocument()
|
|
|
-
|
|
|
- return doc
|
|
|
- })
|
|
|
-
|
|
|
messageHandler.on('LoadFile', async (data) => {
|
|
|
ComPDFKitJS.opened_files = []
|
|
|
ComPDFKitJS.opened_files[0] = data.buffer
|
|
|
+ if (data.pagesPtr && data.pagesPtr.length > 0) {
|
|
|
+ data.pagesPtr.forEach(item => {
|
|
|
+ Module._ClearPage(item.pagePtr)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.doc) {
|
|
|
+ Module._ClearDocument(data.doc)
|
|
|
+ }
|
|
|
|
|
|
if (!data.fontFile) return true
|
|
|
|
|
@@ -2424,9 +2427,6 @@ async function getSignatures({
|
|
|
}
|
|
|
|
|
|
const certPtr = Module._GetSignCert(signerPtr)
|
|
|
-
|
|
|
- let result = false
|
|
|
-
|
|
|
if (certPtr) {
|
|
|
signer.version = Module._GetSignVersion(certPtr)
|
|
|
Module._GetSignAlgOid(certPtr)
|
|
@@ -2482,8 +2482,10 @@ async function getSignatures({
|
|
|
// TODO: 验证证书
|
|
|
CertArray = []
|
|
|
Module._ExportToFilePath(certPtr, 1)
|
|
|
- ComPDFKitJS.opened_cert[0] = CertArray[0]
|
|
|
- result = Module._VerifyGetChain(signerPtr, certPtr, 0, CertArray[0].length)
|
|
|
+ ComPDFKitJS.opened_cert[i] = CertArray[0]
|
|
|
+
|
|
|
+ const certLength = ComPDFKitJS.opened_cert[i].length
|
|
|
+ const result = Module._VerifyGetChain(signerPtr, certPtr, i, certLength)
|
|
|
if (result === 1) {
|
|
|
signer.isCertTrusted = true
|
|
|
for (let f = 0; f < signer.certificateList.length; f++) {
|
|
@@ -2493,9 +2495,13 @@ async function getSignatures({
|
|
|
needCheck = true
|
|
|
}
|
|
|
|
|
|
- const len = ComPDFKitJS.opened_files[0].length
|
|
|
- result = Module._VerifyDocument(doc, signaturePtr, 0, len)
|
|
|
+ const fileLength = ComPDFKitJS.opened_files[0].length
|
|
|
+ const signerResult = Module._VerifySigner(signaturePtr, signerPtr, 0, fileLength)
|
|
|
|
|
|
+ const signatureResult = Module._VerifyDocument(doc, signaturePtr, 0, fileLength)
|
|
|
+ if (signatureResult === 1) {
|
|
|
+ signer.isSignVerified = true
|
|
|
+ }
|
|
|
CertArray = []
|
|
|
Module._GetSignCertChain(certPtr)
|
|
|
|