Understanding JAR signing

The following link says that the public key that corresponds to the private key used to sign the JAR is placed in the JAR, along with its certificate.

http://java.sun.com/docs/books/tutorial/deployment/jar/intro.html

I have a couple of questions: are both the public key and certificate in the DSA file? (The document makes it seem like the public key and its certificate are separate - but doesn't the certificate contain the public key its certifying?)

Are the only 2 ways the public certificate trusted is if the public certificate is imported into the "cacerts" file or into another keystore specified in the jarsigner -verify command? (In the cacerts case you could just omit options relating to the keystore?)

Why are the SHA1-Digest values different in MANIFEST.MF and the SF file for a given file within the JAR?

What's the difference between the SHA1-Digest-Manifest and SHA1-Digest-Manifest-Main-Attributes values in the SF files?

Thanks.

[993 byte] By [lightbulb4321a] at [2007-11-27 6:09:49]
# 1

I know some answers:

1. Yes, public key is inside the certificate, in DSA file

2. AFAIK, if the certificate is signed by someone in the cacerts file, it's OK

3. In MANIFEST.MF, hash value is for file content. In SF file, hash value is for the section in MANIFEST.MF

4. SHA1-Digest-Manifest-Main-Attributes is the hash value for the header part of MANIFEST.MF

You can find out all the details by reading the source codes in OpenJDK.

BTW, Are you going to write a jarsigner yourself?

wangwja at 2007-7-12 17:14:22 > top of Java-index,Security,Other Security APIs, Tools, and Issues...