简体   繁体   English

Java:使用现有 pfx 证书签署 PDF

[英]Java: Signing a PDF with an existig pfx-certificate

I guess my question is rather simple.我想我的问题很简单。 All I found in my research were threads with very short answers sounding like "DAT SO EZ LUK HEER NAP: link".. I tried those links and they were all 404.. So I'm exposing myself to another public execution and will try this thread a millionth time.我在研究中发现的所有内容都是答案非常简短的线程,听起来像“DAT SO EZ LUK HEER NAP:链接”。我尝试了这些链接,它们都是 404。所以我将自己暴露在另一个公开处决中,并会尝试这个线程百万次。

I'm working with PDFBox 2.0.17 and I am trying to sign a PDF-File with an already existing pfx-certificate.我正在使用 PDFBox 2.0.17,我正在尝试使用现有的 pfx 证书签署 PDF 文件。 Thats pretty much everything.这几乎就是一切。 I got some pretty disgusting solutions myself with printing the file via pdf-Creator and stuff, but there must be a smoother, nicer solution.通过 pdf-Creator 和其他东西打印文件,我自己得到了一些非常恶心的解决方案,但必须有一个更流畅、更好的解决方案。

I'd be pretty thankful for every non-404-Link and will accept any kind of public humiliation.我会非常感谢每一个非 404 链接,并且会接受任何形式的公开羞辱。

Best regards, YXCD最好的问候, YXCD

PS: Of course I found solutions like PDFone and other providers. PS:当然,我找到了 PDFone 和其他提供商的解决方案。 But I'm trying to do this without getting myself bankrupt..但我正在努力做到这一点而不让自己破产..

Okay, to sum this up..好吧,总结一下。。

My experience here is that PDFBox has some very precise dependencies which will throw Exceptions the moment they are slightly out of version.我在这里的经验是 PDFBox 有一些非常精确的依赖关系,当它们稍微超出版本时就会抛出异常。 I fixed every problem by first of all reloading the entire PDFBox-Files and then downloading every dependencies the exact version as listed in the PDFBox Version.我通过首先重新加载整个 PDFBox 文件然后下载 PDFBox 版本中列出的确切版本的每个依赖项来解决每个问题。 Using newer versions will throw exceptions.使用较新的版本会抛出异常。

At the end I took the CreateSignature-Example and rewrote it for my needs.最后,我采用了 CreateSignature-Example 并根据我的需要重写了它。 Then it all worked perfectly and smoothly.然后一切都完美而顺利地进行。

Thanks to @mkl and @TilmanHausherr for your comments and giving me the right guidelines.感谢@mkl 和@TilmanHausherr 的评论并为我提供了正确的指导方针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM