How to use OpenSSL to validate a *.SF / *.RSA signature created by the Jarsigner

穿精又带淫゛_ 提交于 2019-12-06 13:58:26

I am an idiot. At the start of this project I knew that the signature format had to be either DER or PEM. I thought I had configured this correctly, but somehow it ended up in the situation where the Jarsigner's signature was in DER format when I wanted to verify a PEM signature.

My solution is to always expect a DER signature. This is default for the Jarsigner. For my OpenSSL signer/verifier I had to make sure the outform and inform was der: -outform der and -inform der.

Code wise I had to change this:

if (!(p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL))) {

into this:

if (!(p7 = d2i_PKCS7_bio(in, NULL))) {

If you want to do check the certificate chain using command-line tools, here is how:

unzip -p your.jar META-INF/*.RSA | openssl pkcs7 -inform DER -text -print_certs
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!