Add trusted certificate

Hello,

I am trying the free version of the viewer (using Javascript) to test if my document signature is valid.
The PDFTron viewer says the document integrity is valid (the document has not been changed since it was signed), but it also says"Trust could not be established".

I did try to add my PEM file of my certificate like this :

				var bytes = []; // char codes

				for (var i = 0; i < me.options.certificate.length; ++i) {
					var code = me.options.certificate.charCodeAt(i);
					bytes = bytes.concat([code & 0xff, code / 256 >>> 0]);
				}

				VerificationOptions.addTrustedCertificates([bytes]);

where “me.options.certificate” is my PEM file as string.

But the viewer still doesn’t validate the certificate.

What did I do wrong ? Thank you.

Please note that there is a difference between the trust flag handling between AddTrustedCertificates and AddTrustedCertificate.

The API you are using

This overload takes no account of trust-level flags because none are available in the P7C format. Therefore, when this function is used, all certificates in the P7C file will be loaded as if trusted for everything, which may lead to false positives when compared to other PDF software. (Most applications use the FDF Cert Exchange format.) The FDF-trust-list-loading function “LoadTrustList” should be used instead whenever possible.

However, this is probably not the main issue you are having.

Please send us your signed PDF and public-key root certificate.

Hello, this is the self signed certificate, the public key PEM file I used as string in “me.options.certificate” and the PDF file I signed.
sample1 (29).pdf (59.6 KB)

Maybe the input for “addTrustedCertificates” is the wrong one ? I should maybe use the PEM certificate file instead of public key file?

Thank you for helping

public key PEM :

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArG1XmB+UZo9yZiCDPLCq
K+eaXb96rHAG4fvXXxitYdVrCJtYxzXN9ALj10giZIp3DkJcsAzgdv40gjWljrM3
SJz+BvxlQs7eixo5J+cl1IOpYdQHSi9uv95U96gBDZKA1LJvkeV4OEyx2f497myj
UJsD7pGmYQ8MkGFic67zm1jhiM9IfcB9DrWr5uj8F1Rhii1R1fnAJ8ScgmV5zGXC
/ikv8yWKC4Phjpz+qKwkU+dDi2Cr3AAIPskj+xA3cJpMsf+6D06q9pPKLpi7ADXg
dFrQk0bDllqtuF1Xh2OAKm2/HAM5flPKljHUcRbbPaMqUmn08oHYpLxb/XvvbWGf
iQI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