Bug 11485 - [jar exporter] jarsigner/keytool integration
Summary: [jar exporter] jarsigner/keytool integration
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P5 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 341112 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-15 13:22 EST by Stefan J. Morgenroth CLA
Modified: 2017-05-12 04:28 EDT (History)
9 users (show)

See Also:


Attachments
prototype jar signer (22.78 KB, application/octet-stream)
2008-01-08 05:48 EST, Brock Janiczak CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan J. Morgenroth CLA 2002-03-15 13:22:21 EST
An integration of the jarsigner and the keytools would be nice.

It could be made in two main steps.
1. An option in the JAR-Export to simple sign the JAR with an previous external
created key. So people should create their keys seperate by command line to use
them.
2. A "module" or maybe a plugin integrated into Eclipse to create/delete and
manage keys.
Comment 1 Erich Gamma CLA 2002-03-18 13:41:40 EST
agreed, that it would be nice, but can't be done for 2.0 unless we get 
external help.
Comment 2 Dirk Baeumer CLA 2002-07-23 09:49:38 EDT
[jar creation]
Comment 3 Dani Megert CLA 2002-08-19 08:36:24 EDT
Nothing planned for 2.1 unless someone provides code/patch
Comment 4 Dirk Baeumer CLA 2003-04-28 06:03:59 EDT
Chaning state from assigned later to resolved later. Assigned later got 
introduced by the last bug conversion and is not a supported Eclipse bug state.
Comment 5 Brock Janiczak CLA 2008-01-02 05:24:55 EST
I have recently implemented a jar signer and would be willing to integrate it into eclipse.  It is currently a standalone application, but shouldn't be too hard to adapt to JarBuilder and JarWriter3.  It has no references to any internal Sun packages, so should run on any 1.4 JRE.

Would it be possible to re-open this issue and consider the contribution?

Also, any help you could provide with integrating into the existing jar export would also be greatly appreciated.  Signed jars have a unique requirement for needing to read files twice, once for the digests and once when adding to the final jar.  This doesn't fit so well with the current implementation.  A possible solution would be to just write the jar out once, then post process it, but this is pretty inefficient.
Comment 6 Benno Baumgartner CLA 2008-01-07 09:57:37 EST
(In reply to comment #5)
> I have recently implemented a jar signer and would be willing to integrate it
> into eclipse.  It is currently a standalone application, but shouldn't be too
> hard to adapt to JarBuilder and JarWriter3.  

Can I try this application? It's not a plugin, correct?

> It has no references to any
> internal Sun packages, so should run on any 1.4 JRE.

Does it call the external jarsign tool, or is this all implemented in Java?

> Would it be possible to re-open this issue and consider the contribution?

Sure.

> Also, any help you could provide with integrating into the existing jar export
> would also be greatly appreciated.  Signed jars have a unique requirement for
> needing to read files twice, once for the digests and once when adding to the
> final jar.  This doesn't fit so well with the current implementation.  A
> possible solution would be to just write the jar out once, then post process
> it, but this is pretty inefficient.

Sure I can help. But be aware, that if this requires to change existing API we would have to integrate it before M5, which means till end of January the latest.

Comment 7 Brock Janiczak CLA 2008-01-08 05:48:52 EST
Created attachment 86390 [details]
prototype jar signer

I have attached the prototype jar signer.  So far it is a standalone application (you all params are hard coded right now).  The program can be run from the JarSigner class (this is where the params are hard coded)

Although it is functional, it is clearly a prototype

the following things are outstanding:
1. No unit tests at all
2. Various suspected bugs in the BER encoder (especially with encoding negative integers)
3. Some unfinished types in the BER encoder (unused by the jar signer)
4. Some fields are not being populated (or encoded), such as the hash algorithm properties
5. Support the 'internalsf' param (just places the signature file in the signature block's data section)
6. Supplied certificate chain is not being checked for expiration or anything
7. Add support for progress monitoring

I think it might make sense to convert the BER encoder into an OSGi bundle so it can be used by any future equinox security work that needs to encode stuff.  The BER decoder from equinox could be added to the bundle too.
Comment 8 Benno Baumgartner CLA 2008-01-08 06:44:17 EST
(In reply to comment #7)
> Created an attachment (id=86390) [details]
> prototype jar signer
> 
> I have attached the prototype jar signer.  So far it is a standalone
> application (you all params are hard coded right now).  The program can be run
> from the JarSigner class (this is where the params are hard coded)

Thank you! Wow, this looks super complex:
-Do you have a link to some specification for the jar signing? 
-Doesn't a open source BER encoder Java implementation already exist (inside or outside of eclipse) which we could reuse? All the array copies look inefficient to me. I agree with you that JDT seams to be the wrong place for such functionality.
-Did you write all this code yourself? We certainly will need legal approval to integrate this.
-Please be aware that, in order to integrate this into JDT, the code must be converted to Java 1.4.
Comment 9 Brock Janiczak CLA 2008-01-08 07:07:01 EST
unfortunately, most of the code is all mine :(
The bas64 encoder was coped from org.eclipse.osgi (they have a ber decoder too).  Some of the PKCS7 constants were also copied from org.eclipse.osgi.  Any class that was a copy should have the eclipse header.  All new stuff has no header at all.

There isn't much in the way of resources, but the jar spec is here:
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Signed%20JAR%20File
says that the signature block is PKCS#7 which is defined here:
http://tools.ietf.org/html/rfc2315

This links to about a million other ones

I figured it out by creating a signature block with the Sun jar signer then trying to make mine output the same values, based on the specification.

Removing the java5 stuff should be easy (only used generics to make the code easier for me to read).  Should be nothing Java5 specific other than that

The BER encoder is really inefficient, but I am not sure it can easily fixed.  It is a Tag Length Value format and to calculate the length of a 'structure' you need to calculate the length of all of its children.  There is probably an encoder in Apache Commons somewhere, but equinox already has a BER decoder, so i thought adding an encoder would be a good match.  I have no emotional attachment to it though (since it is really buggy and incomplete).
Comment 10 Benno Baumgartner CLA 2008-01-08 08:33:31 EST
(In reply to comment #9)
> unfortunately, most of the code is all mine :(

I'm sorry, but I have to tell you, that reimplementing the jarsign tool is a no-go for us. I assumed, that your application just calls the jarsign tool from a given SDK, like the eclipse javadoc exporter does for the javadoc tool. This would be the way for us to go. 
Comment 11 Denis Roy CLA 2009-08-30 02:20:12 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.
Comment 12 Krzysztof Daniel CLA 2010-02-18 04:44:40 EST
This is actually a nice-to-have and it is still valid.
Comment 13 Dani Megert CLA 2011-03-29 02:38:49 EDT
*** Bug 341112 has been marked as a duplicate of this bug. ***
Comment 14 Kevin Hine CLA 2011-03-29 04:16:35 EDT
This is becoming more of a gap in the JDT for us.  All of our web based (ie. most) JARs are signed.  To need drop down out of the native builder to an ant script is cumbersome.
Comment 15 Leonardo Pessoa CLA 2017-05-11 13:58:09 EDT
Any updates on this issue?
Comment 16 Dani Megert CLA 2017-05-12 04:28:07 EDT
(In reply to Leonardo Pessoa from comment #15)
> Any updates on this issue?

A high quality patch is welcome.