Tibin
Tibin

Reputation: 644

Sign PDF Document using certificate and private key with iText 5

I have a certificate which is used for tls/SSL in my web server. The certificate was issued by a trusted authority and I am having the RSA private key and x509 certificate for the same. The key usage of the certificate says that it can be used for digital signature. Now i need to digitally sign PDF using that certificate, but in all examples, they are asking for a pkcs12 file which I don't have. Is there is any solution that i can sign the pdf using that key and cer or i can generate the pkcs12 using any openssl command?

Upvotes: 1

Views: 3010

Answers (1)

pedrofb
pedrofb

Reputation: 39241

It is strange that a certificate can be used for TLS and for digital signature. Usually the key usage is different and the common name matches the domain name.

If that is your requirement you can build a pkcs12 with openssl from key and x509 certificate

 openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

You can also sign the PDF using directly key and certificate (it is not mandatory to include them into a .p12 file). See some itext digital signature examples hre

Upvotes: 2

Related Questions