Signing .jar file with a .cer file

Viewed 25922

I'm trying to sign a jar file with a code signing certificate issued by globalsign.

I'm completely new to this but after some googling and a lot of trial and error, I executed the following steps.

I've imported the certificate in my keystore using:

keytool -importcert -alias signalias -file OS200912023195.cer

When I try to sign my jar file using:

jarsigner applet.jar signalias

I get the following error:

jarsigner: Certificate chain not found for: signalias. signalias must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.

Did I forget something or lies the problem with the certificate?

5 Answers

jarsigner: Certificate chain not found for: signalias. signalias must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.

I got that error when I created my Certificate Signing Request (CSR) using an openssl command instead of using keytool. The result is that when I generated my keystore, it didn't contain the private key, only the certificate that I had imported.

This post fixed my problem: Can a Java key store import a key pair generated by OpenSSL?

After creating the key and the certificate with OpenSSL, use OpenSSL to create a PKCS #12 key store:

openssl pkcs12 -export -in cert.pem -inkey key.pem > server.p12

Then convert this store into a Java key store:

keytool -importkeystore -srckeystore server.p12 -destkeystore server.jks -srcstoretype pkcs12

Related