On this page
Guides
Trust Certificate
Trusting certificates involve two steps:
Specify the trust path (folder) for certificates. This path serves as the location where certificates are placed when they are trusted. Additionally, when checking the trustworthiness of certificates, the SDK will look for the corresponding certificates within this folder. Please ensure that this path is valid. If the path does not exist or is inaccessible, the ComPDFKit SDK will not automatically create the trust path folder.
Execute the method to trust certificates, and the certificates will be added to the trust path.
This example shows how to trust certificates:
swift
if let url = Bundle.main.url(forResource: "filename", withExtension: "pdf") {
let document = CPDFDocument(url: url)
if let signatures = document?.signatures, let signature = signatures.first,
let signer = signature.signers.first, let certificate = signer.certificates.first {
certificate.checkCertificateIsTrusted()
let success = certificate.addToTrustedCertificates()
certificate.checkCertificateIsTrusted()
}
}
objective-c
NSURL *url = [NSURL fileURLWithPath:@"file path"];
CPDFDocument *document = [[CPDFDocument alloc] initWithURL:url];
NSArray *signatures = [document signatures];
CPDFSignature *signature = signatures[0];
CPDFSigner *signer = signature.signers.firstObject;
CPDFSignatureCertificate * certificate = signer.certificates.firstObject;
[certificate checkCertificateIsTrusted];
BOOL success = [certificate addToTrustedCertificates];
[certificate checkCertificateIsTrusted];