How to digitally sign a PDF using X.509 certificate data from an iOS application

I am creating a PDF in my application. I want to provide the best protection for these PDF files created through my application. I have added default security options provided by Apple, such as owner password, allow copying, allow printing, etc.

But I would like to add my certificate information or call it the signature number in pdf format using user certificate certificates (X.509).

Does security help? or How can this be achieved?

+6
source share
1 answer

Unfortunately, iOS doesn't seem to provide this feature natively . Finding a library that will apply a digital signature to a PDF document is difficult, as many tools use handwritten signature images. It seems that there is no C or Objective-C that you could use on iOS, most implementations are in Java or C # or not available on iPhone (like Acrobat SDK or PLOP DS ).

You can nevertheless implement your own digital signature , it is quite simple and documented . You will need to serialize the PDF document, as indicated in this document, make a place for the signature object (this requires minimal analysis of the PDF layout), then calculate the signature and save it in a file.

For the cryptographic part, it seems that the Security Framework does not provide an API for creating the required PKCS # 7 signature. Thus, you can use OpenSSL instead.

+1
source

Source: https://habr.com/ru/post/957814/


All Articles