jarsigner -verify works in Java 6 but not Java 7

余生颓废 提交于 2019-12-03 15:29:04

The answer to your problem is you are using SUN as your keystore provider java 6 was released prior to oracle purchasing SUN and java 7 was released after and many of the Sun packages are now deprecated. You can verify this here.

Oracle has kept support for the deprecated SUN keystore provider but now requires that a warning be issued same as if you had used any deprecated feature.

There is a long detailed description written by Oracle on why you shouldn't use the SUN provider for security signing in the JCA Documentation on their website.

The only thing that will "fix" this is to change your keystore provider to and oracle acceptable one, you can find them in the same security documentation linked to above.

Hope that helps.

It does work. You get "jar verified" in both cases => the JAR is verified in both cases. That means that the JAR was signed by who it claims to be signed by, and that the JAR hasn't been subsequently tampered with.

Java 7 is printing a warning.

Jason Nichols

Months later I happened to figure out the answer to my own question. For anyone else with the same issue, here is what I did:

  1. Convert your existing private key and the CA signed cert into a pkcs12 format (this is required since Java's keytool doesn't allow the direct importation of these items). This can be accomplished in a single openssl command:

    openssl pkcs12 -export -name signing -in signing.cert -inkey myPrivateKey.key -out keystore.p12
    

    Where signing is the name of my pkcs12 keystore, signing.cert is my CA supplied signed cert, and (obviously) myPrivateKey.key is my private key that was used to sign the Cert Request.

  2. Import this newly created keystore into a Java keystore:

    keytool -importkeystore -destkeystore keystore -srckeystore keystore.p12 -srcstoretype pkcs12 -alias signing
    
  3. Import your CA's Java cert into the keystore. I'm not exactly sure what magic this does but without it the cert chain isn't followed (even when manually adding intermediate certs). This cert is usually provided via the email where your signing cert arrived in. For our purposes it's called signing.pkcs7.

    keytool -importcert -file signing.pkcs7 -keystore keystore -v -alias signing
    

    You'll have to enter the keystore password you used when creating the Java keystore.

  4. Use the maven-jarsigner-plugin (or whatever automation is required) to sign your projects during build.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!