Bug 401098 - [CBI] Inner jars are not signed in CBI based build
Summary: [CBI] Inner jars are not signed in CBI based build
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P2 major with 1 vote (vote)
Target Milestone: 4.4 M2   Edit
Assignee: Platform-Releng-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 408901 411847 (view as bug list)
Depends on: 401141
Blocks: 372792 393922
  Show dependency tree
 
Reported: 2013-02-18 10:32 EST by Thomas Watson CLA
Modified: 2014-06-23 16:57 EDT (History)
11 users (show)

See Also:


Attachments
innerjars that require action (14.39 KB, text/plain)
2013-08-28 23:26 EDT, David Williams CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Watson CLA 2013-02-18 10:32:06 EST
Looking at the osgi.tests logs for the test failures of the latest CBI based builds [1] I noticed that the following exception is getting thrown when trying to launch a session of eclipse with some security options enabled:

Caused by: java.lang.SecurityException: class "org.eclipse.core.runtime.IExtension"'s signer information does not match signer information of other classes in the same package
	at java.lang.ClassLoader.checkCerts(ClassLoader.java:806)
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:620)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:574)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
	at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	at org.eclipse.core.runtime.RegistryFactory.createRegistry(RegistryFactory.java:58)
	at org.eclipse.core.internal.registry.osgi.Activator.startRegistry(Activator.java:137)
	at org.eclipse.core.internal.registry.osgi.Activator.start(Activator.java:56)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	... 69 more


This is an indication that the org.eclipse.equinox.registry bundle is not signed with the same signer as the org.eclipse.core.runtime.compatibility.registry bundle.  As it turns out both bundles ARE signed with the same signer, but the difference is the inner jar (runtime_registry_compatibility.jar) for the org.eclipse.core.runtime.compatibility.registry bundle is no longer signed in the CBI based build, but it is signed in the PDE based build.

[1] - http://download.eclipse.org/eclipse/downloads/drops4cbibased/I20130216-2011/testresults/linux.gtk.x86_6.0/org.eclipse.osgi.tests.AutomatedTests.txt
Comment 1 Thomas Watson CLA 2013-02-18 14:05:40 EST
I released a workaround to disable defining the class with the jar signing  certificate to work around the issue for now so we can get green tests from OSGi:

http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/?id=2bf140c910f5fd4651fcfc798610b7da950d1e51


I do think it is important to figure this one out since a mismatch in the registry host and the compatibility fragment jar have caused us issues in the past.
Comment 2 David Williams CLA 2013-04-21 14:26:54 EDT
Would be best to restore same behavior for Kepler (so marked as p2) but believe the severity is correct, normal, not major.
Comment 3 Thomas Watson CLA 2013-05-24 11:01:45 EDT
*** Bug 408901 has been marked as a duplicate of this bug. ***
Comment 4 Fabio Zadrozny CLA 2013-05-24 11:57:15 EDT
Hi, I was discussing this previously in https://bugs.eclipse.org/bugs/show_bug.cgi?id=408901, and I don't believe this is of normal priority... without that, I simply can't run tests that rely on a classloader (which I think is currently the only way to run a test in Eclipse itself for multiple projects at once).

So, this makes http://johanneslink.net/projects/cpsuite.jsp and the junit 3 ClassPathTestCollector unusable, which for me is a real blocker (i.e.: I don't think an Eclipse 4.3 final can be launched without this fixed).
Comment 5 Thomas Watson CLA 2013-05-24 12:08:27 EDT
Also see bug 401141 which this bug depends on.
Comment 6 David Williams CLA 2013-05-25 00:05:01 EDT
(In reply to comment #4)
> Hi, I was discussing this previously in
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=408901, and I don't believe
> this is of normal priority... without that, I simply can't run tests that
> rely on a classloader (which I think is currently the only way to run a test
> in Eclipse itself for multiple projects at once).
> 
> So, this makes http://johanneslink.net/projects/cpsuite.jsp and the junit 3
> ClassPathTestCollector unusable, which for me is a real blocker (i.e.: I
> don't think an Eclipse 4.3 final can be launched without this fixed).

Fabio, since this is a problem for you running unit tests, not in a deployed application, I assume, I am wondering if there is a temporary work-around where you can tell the Java VM to "relax" its security policy's? 

http://docs.oracle.com/javase/7/docs/technotes/guides/security/

I don't know much about it first hand, but glancing at the above document seemed to provide some techniques/settings to do that. 

Let us know if that's possible.
Comment 7 David Williams CLA 2013-05-25 00:07:55 EDT
(In reply to comment #6)
> (In reply to comment #4)

> 
> http://docs.oracle.com/javase/7/docs/technotes/guides/security/
> 

Or, perhaps try Tom's code workaround in comment 1 link.
Comment 8 David Williams CLA 2013-05-26 23:29:23 EDT
FWIW, I wrote a little batch script to see how many "inner jars" we have ... and turns out to be a lot ... but does not really help in knowing which should be signed and which should not be. I've added them as attachments to bug 409074 based on RC2 build.
Comment 9 David Williams CLA 2013-05-27 18:04:09 EDT
Setting as SR1 meaning "candidate" ... depends on CBI signer being fixed ... but, this seems pretty important, to me.
Comment 10 Fabio Zadrozny CLA 2013-06-04 14:12:31 EDT
David: I don't see a way I can use that workaround from comment when developing things (and couldn't work around it with the security settings either).

Is there someone taking a look at this? I'd really like to work with the latest RCs to check if things work, but without this fixed I'm stuck at 4.3m7.
Comment 11 Dani Megert CLA 2013-06-05 10:21:12 EDT
(In reply to comment #9)
> Setting as SR1 meaning "candidate" ... depends on CBI signer being fixed ...
> but, this seems pretty important, to me.

I guess you meant 4.3.1.
Comment 12 Thomas Watson CLA 2013-06-28 08:39:39 EDT
*** Bug 411847 has been marked as a duplicate of this bug. ***
Comment 13 David Williams CLA 2013-08-28 23:26:56 EDT
Created attachment 234890 [details]
innerjars that require action

Attached is an edited (simplified) version of the comparator log from I20130828-1800 build. For full log, see 
http://download.eclipse.org/eclipse/downloads/drops4/I20130828-1800/buildlogs/comparatorlogs/buildtimeComparatorUnanticipated.log.txt
The attachment lists bundles who's inner jars differ (due to new builds being signed, but older ones, with same qualifier, are not signed). 


Now that "signing inner jars" is turned on, there are approximately 70 bundles that require one action or another, directly or indirectly. See http://dev.eclipse.org/mhonarc/lists/eclipse-dev/msg09638.html
for Thanh's announcement of this new function. 

There are actually two potential actions committers need to take, depending on their requirements: 

1. If you WANT the inner jars signed (as in a few equinox cases, maybe others?) then you need to "touch" the bundle so that the qualifier is updated and the version with signed inner jars becomes the distributed one, instead of being replaced by the comparator with an older unsigned version. 

2. If you do NOT WANT the inner jars signed (as would be the case with nearly all the test bundles) then you need to 

A. modify the POM file, as described in bug 412850 comment 28. See also bug 412850 comment 36 for some possibly late breaking news. 
For those cases where you have a "test parent", you can add the "sign" profile (with the "exclude inner jars = true" setting), just to that test parent and it will be inherited. 

B. AND ... THEN you MIGHT need to touch the bundles involved so the "not signed" version becomes most current and becomes the distributed one (this depends on if the bundle has changed, for other reasons, and the signed version is now current. 

It's fine to do in several passes, and see what the comparator and unit tests report. I'm going to propose we do I builds every night for a week or so so progress can be more incremental.
Comment 14 Dani Megert CLA 2013-08-29 07:19:15 EDT
(In reply to comment #13)
> 2. If you do NOT WANT the inner jars signed (as would be the case with
> nearly all the test bundles) then you need to 
> 
> A. modify the POM file, as described in bug 412850 comment 28. See also bug
> 412850 comment 36 for some possibly late breaking news. 
> For those cases where you have a "test parent", you can add the "sign"
> profile (with the "exclude inner jars = true" setting), just to that test
> parent and it will be inherited. 
> 
> B. AND ... THEN you MIGHT need to touch the bundles involved so the "not
> signed" version becomes most current and becomes the distributed one (this
> depends on if the bundle has changed, for other reasons, and the signed
> version is now current. 

Isn't the information in the 'eclipse.inf':
  jarprocessor.exclude.pack=true
  jarprocessor.exclude.children=true4
used? JDT Core tests specify this, but their inner JAR still seems to get signed (see bug 416106).
Comment 15 David Williams CLA 2013-08-29 07:50:05 EDT
(In reply to comment #14)
> (In reply to comment #13)
> > 2. If you do NOT WANT the inner jars signed (as would be the case with
> > nearly all the test bundles) then you need to 
> > 
> > A. modify the POM file, as described in bug 412850 comment 28. See also bug
> > 412850 comment 36 for some possibly late breaking news. 
> > For those cases where you have a "test parent", you can add the "sign"
> > profile (with the "exclude inner jars = true" setting), just to that test
> > parent and it will be inherited. 
> > 
> > B. AND ... THEN you MIGHT need to touch the bundles involved so the "not
> > signed" version becomes most current and becomes the distributed one (this
> > depends on if the bundle has changed, for other reasons, and the signed
> > version is now current. 
> 
> Isn't the information in the 'eclipse.inf':
>   jarprocessor.exclude.pack=true
>   jarprocessor.exclude.children=true4
> used? JDT Core tests specify this, but their inner JAR still seems to get
> signed (see bug 416106).

No, not used by Tycho. There is a number of bugs about this, but bottom line is they only partially support "eclipse.inf" at all. I'm "lost in the maze of bugs" at the moment, and can't point you to specific bug numbers.
Comment 16 Thanh Ha CLA 2013-08-29 09:28:48 EDT
(In reply to comment #15)
> No, not used by Tycho. There is a number of bugs about this, but bottom line
> is they only partially support "eclipse.inf" at all. I'm "lost in the maze
> of bugs" at the moment, and can't point you to specific bug numbers.

We've proposed 2 different methods. The first method (bug 401141) we were going to depend on the existing MANIFEST.MF to allow excluding children but it caused Bug 412850 due to Tycho not supporting the MANIFEST.MF file to which we raised bug 413282 but it appears it may be difficult to implement in Tycho.

So we decided to go with method 2 which is to fix it in CBI's jarsigner plugin by adding the new pom configuration.
Comment 17 Thanh Ha CLA 2013-08-29 09:37:52 EDT
(In reply to comment #16)
> We've proposed 2 different methods. The first method (bug 401141) we were
> going to depend on the existing MANIFEST.MF to allow excluding children but
> it caused Bug 412850 due to Tycho not supporting the MANIFEST.MF file to
> which we raised bug 413282 but it appears it may be difficult to implement
> in Tycho.


And by MANIFEST.MF I meant eclipse.inf sorry...
Comment 18 Dani Megert CLA 2013-09-05 07:23:36 EDT
(In reply to David Williams from comment #13)
> 2. If you do NOT WANT the inner jars signed (as would be the case with
> nearly all the test bundles) then you need to 

For most test bundles signing won't hurt and hence touching them is enough. However, we need to exclude signing for all JARs that contain Ant tasks to avoid performance penalties (for details see bug 163549 comment 0). I've disabled inner JAR signing for the following bundles:

org.eclipse.ant.core
org.eclipse.ant.launching
org.eclipse.ant.ui
org.eclipse.help.base
org.eclipse.jdt.core
org.eclipse.pde.core
Comment 19 Dani Megert CLA 2013-09-05 07:42:51 EDT
(In reply to Dani Megert from comment #18)
> (In reply to David Williams from comment #13)
> > 2. If you do NOT WANT the inner jars signed (as would be the case with
> > nearly all the test bundles) then you need to 
> 
> For most test bundles signing won't hurt and hence touching them is enough.
> However, we need to exclude signing for all JARs that contain Ant tasks to
> avoid performance penalties (for details see bug 163549 comment 0). I've
> disabled inner JAR signing for the following bundles:
> 
> org.eclipse.ant.core
> org.eclipse.ant.launching
> org.eclipse.ant.ui
> org.eclipse.help.base
> org.eclipse.jdt.core
> org.eclipse.pde.core

I also seem some of those in Equinox.
Comment 20 Dani Megert CLA 2013-09-05 07:58:25 EDT
(In reply to Dani Megert from comment #18)
> (In reply to David Williams from comment #13)
> > 2. If you do NOT WANT the inner jars signed (as would be the case with
> > nearly all the test bundles) then you need to 
> 
> For most test bundles signing won't hurt and hence touching them is enough.
> However, we need to exclude signing for all JARs that contain Ant tasks to
> avoid performance penalties (for details see bug 163549 comment 0). I've
> disabled inner JAR signing for the following bundles:
> 
> org.eclipse.ant.core
> org.eclipse.ant.launching
> org.eclipse.ant.ui
> org.eclipse.help.base
> org.eclipse.jdt.core
> org.eclipse.pde.core

And done for org.eclipse.pde.api.tools
Comment 21 David Williams CLA 2013-09-05 08:06:15 EDT
(In reply to Dani Megert from comment #19)
> (In reply to Dani Megert from comment #18)
> > (In reply to David Williams from comment #13)
> > > 2. If you do NOT WANT the inner jars signed (as would be the case with
> > > nearly all the test bundles) then you need to 
> > 
> > For most test bundles signing won't hurt and hence touching them is enough.
> > However, we need to exclude signing for all JARs that contain Ant tasks to
> > avoid performance penalties (for details see bug 163549 comment 0). I've
> > disabled inner JAR signing for the following bundles:
> > 
> > org.eclipse.ant.core
> > org.eclipse.ant.launching
> > org.eclipse.ant.ui
> > org.eclipse.help.base
> > org.eclipse.jdt.core
> > org.eclipse.pde.core
> 
> I also seem some of those in Equinox.

Equinox probably requires the most care. This whole issue, that is, the need to sign inner jars ... came about because some in some cases (especially where a bundle or extension framework has its own classloader) "split packages" and "hosts with fragments" must be "signed by the same certificate" or the classloader is flag as invalid. I'm probably not verbalizing that well (need another cup of tea) but comment 0 probably says it well enough and I'm just urging caution.
Comment 22 Dani Megert CLA 2013-09-10 10:52:26 EDT
There hasn't been much progress lately. Note that M2 is already next week, so please take a look at your component(s) if not done so already.
Comment 23 Thomas Watson CLA 2013-09-10 12:26:52 EDT
(In reply to Dani Megert from comment #22)
> There hasn't been much progress lately. Note that M2 is already next week,
> so please take a look at your component(s) if not done so already.

Equinox should be fine.  I disabled signing of inner jars for the tests.  p2 also has done the same.  All other inner jars in Equinox should be signed.
Comment 24 David Williams CLA 2013-09-10 13:08:45 EDT
(In reply to Thomas Watson from comment #23)
> (In reply to Dani Megert from comment #22)
> > There hasn't been much progress lately. Note that M2 is already next week,
> > so please take a look at your component(s) if not done so already.
> 
> Equinox should be fine.  I disabled signing of inner jars for the tests.  p2
> also has done the same.  All other inner jars in Equinox should be signed.

I've not looked, but assumed you "touched" those you want signed? Otherwise, qualifier won't change, and and old unsigned version will be pulled in by "comparator".
Comment 25 Thomas Watson CLA 2013-09-10 13:19:26 EDT
The inner jar associated with equinox (but is really part of Platform->Core) was touched as part of bug 412852 where the version was increased for Luna.
Comment 26 Dani Megert CLA 2013-09-16 04:25:19 EDT
The following inner JARs that are inside a directory (non-JARed plug-in), are still not signed:

runtime_registry_compatibility.jar in org.eclipse.core.runtime.compatibility.registry

pdebuild.jar in org.eclipse.pde.build
Comment 27 Dani Megert CLA 2013-09-16 04:38:10 EDT
(In reply to Dani Megert from comment #26)
> pdebuild.jar in org.eclipse.pde.build

This is actually expected, but shows the limitations of the current approach: I can only specify that a plug-in with all its inner JARs is excluded.  'org.eclipse.pde.build' is shipped as non-JARed bundle where we would want to sign the 'pdebuild.jar' that has the "normal" class files, but we'd like to exclude the library which contains the Ant tasks from signing (lib/pdebuild-ant.jar). As far as I know this is currently not possible. In PDE Build one could simply specify this per JAR via 'eclipse.inf'.
Comment 28 Thomas Watson CLA 2013-09-16 08:44:52 EDT
(In reply to Dani Megert from comment #26)
> The following inner JARs that are inside a directory (non-JARed plug-in),
> are still not signed:
> 
> runtime_registry_compatibility.jar in
> org.eclipse.core.runtime.compatibility.registry

I touched the bundle again:

http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=e7ac5a380f7b7c4d2f9e07eb8ab79363bda13f8a

Not sure when the signing got lost on it again.
Comment 29 Dani Megert CLA 2013-09-19 08:52:28 EDT
(In reply to Thomas Watson from comment #28)
> (In reply to Dani Megert from comment #26)
> > The following inner JARs that are inside a directory (non-JARed plug-in),
> > are still not signed:
> > 
> > runtime_registry_compatibility.jar in
> > org.eclipse.core.runtime.compatibility.registry
> 
> I touched the bundle again:
> 
> http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/
> ?id=e7ac5a380f7b7c4d2f9e07eb8ab79363bda13f8a
> 
> Not sure when the signing got lost on it again.

Looks good now. Closing as FIXED.
Comment 30 Beck Yang CLA 2014-01-22 21:03:29 EST
Can you fix this bug in version 4.3.2? 
The problem still exists in 4.3.2 RC1 and Maintenance Build: M20140122-1000
Comment 31 David Williams CLA 2014-01-23 14:48:06 EST
(In reply to Beck Yang from comment #30)
> Can you fix this bug in version 4.3.2? 
> The problem still exists in 4.3.2 RC1 and Maintenance Build: M20140122-1000

That was certainly our original intent, since its obviously important to some people, but it turned out to be more change (and work) than we originally thought, so I certainly do not have the authority to decide. 

Dani, and Tom, I think the decision is up to you too. 

I know from a "releng" point of view, we would have to change the version of tycho and cbi we use in maintenance. I think in general this is very low risk ... but, if I recall, where were a few tweaks we had to make (that were not related to inner jar signing). 

What we currently use, in master, is 
    <tycho.version>0.19.0</tycho.version>
    <tycho-extras.version>0.19.0</tycho-extras.version>
    <cbi-plugins.version>1.0.5</cbi-plugins.version>

(and 0.18.1, and 1.0.4, in maintenance). 

The other factor is that several bundles need to copy/paste the "inner signing off" code to their POMs and then to be "touched". 

In other words, a fair amount of work to do in one week, for RC2. 

I certainly don't mind ... but know there are many other priorities, so it is a "tough call". 

Beck, and others that need this in "Kepler" ... I suggest you state, again, why you consider it "blocking" and what impact it would have if not fixed.
Comment 32 Dani Megert CLA 2014-01-28 08:26:21 EST
(In reply to David Williams from comment #31)
> (In reply to Beck Yang from comment #30)
> > Can you fix this bug in version 4.3.2? 
> > The problem still exists in 4.3.2 RC1 and Maintenance Build: M20140122-1000
> 
> That was certainly our original intent, since its obviously important to
> some people, but it turned out to be more change (and work) than we
> originally thought, so I certainly do not have the authority to decide. 
> 
> Dani, and Tom, I think the decision is up to you too. 

No, we won't backport this. As mentioned, many changes were involved and RC2 is tomorrow. Also note that even with the fix, i.e. in 4.4 M5, we have several inner JARs that aren't and can't be signed (e.g. all those with Ant tasks). Plus, some bundles from Orbit also don't have their inner JAR(s) signed (e.g. 'org.junit').
Comment 33 Ashish Tyagi CLA 2014-06-23 14:10:24 EDT
(In reply to Thomas Watson from comment #1)
> I released a workaround to disable defining the class with the jar signing 
> certificate to work around the issue for now so we can get green tests from
> OSGi:
> 
> http://git.eclipse.org/c/equinox/rt.equinox.framework.git/commit/
> ?id=2bf140c910f5fd4651fcfc798610b7da950d1e51
> 
> 
> I do think it is important to figure this one out since a mismatch in the
> registry host and the compatibility fragment jar have caused us issues in
> the past.

How to apply the solution mentioned in the comment. I am facing the same issue while testing my eclipse rcp plugin using powermock and mockito. I am not sure how can I implement your solution. Please help.
Comment 34 Thomas Watson CLA 2014-06-23 16:57:19 EDT
(In reply to Ashish Tyagi from comment #33)
> How to apply the solution mentioned in the comment. I am facing the same
> issue while testing my eclipse rcp plugin using powermock and mockito. I am
> not sure how can I implement your solution. Please help.

I suspect when you are mocking for tests it is not running in an Equinox OSGi framework like is done when launching the actual RCP application.  Outside of an Equinox OSGi framework the code is likely loaded by a "normal" URLClassLoader.  It is not possible to configure these class loaders to ignore signatures at class definition time like we can do for the OSGi bundle class loaders.

How is your testing failing?  What is the stacktrace and error message?  If it is what I suspect you would have to strip the jars of their signatures to workaround it.