Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to sign jnilibs for macOS notarization #7

Closed
jonahgraham opened this issue Aug 3, 2023 · 29 comments
Closed

Need to sign jnilibs for macOS notarization #7

jonahgraham opened this issue Aug 3, 2023 · 29 comments

Comments

@jonahgraham
Copy link

The new version of JFFI contributed here and used by linuxtools (which is included in CPP and Embed CPP package) here causes notarization to fail because the jnilibs are not signed.

In EBR based Orbit we do sign the jnilibs as part of the Orbit process. See this bugzilla for reference the last time JFFI failed and this part of pom.xml for how we sign the jnilibs.

Note that JNA needed signing in the past, but Apple's notarization processes sometimes look arbitrarily deep in jars and provides a moving target that we need to chase regularly. Also, the JNA maintainers are not interested in providing signed jnilibs in their release.

full json of error
{
  "logFormatVersion": 1,
  "jobId": "b0fe30eb-7a90-48a0-9b26-de50880fcd81",
  "status": "Invalid",
  "statusSummary": "Archive contains critical validation errors",
  "statusCode": 4000,
  "archiveFilename": "eclipse-cpp-2023-09-M2-macosx-cocoa-aarch64-6370600730443560226.dmg",
  "uploadDate": "2023-08-03T18:24:52Z",
  "sha256": "320d3da6e1e89a841ba4e796f083ddec1c66e81bb11a1c6c9ab444443b2bdf84",
  "ticketContents": null,
  "issues": [
    {
      "severity": "error",
      "code": null,
      "path": "eclipse-cpp-2023-09-M2-macosx-cocoa-aarch64-6370600730443560226.dmg/Eclipse.app/Contents/Eclipse/plugins/com.github.jnr.jffi.native_1.3.11.jar/jni/Darwin/libjffi-1.2.jnilib",
      "message": "The binary is not signed with a valid Developer ID certificate.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087721",
      "architecture": "x86_64"
    },
    {
      "severity": "error",
      "code": null,
      "path": "eclipse-cpp-2023-09-M2-macosx-cocoa-aarch64-6370600730443560226.dmg/Eclipse.app/Contents/Eclipse/plugins/com.github.jnr.jffi.native_1.3.11.jar/jni/Darwin/libjffi-1.2.jnilib",
      "message": "The signature does not include a secure timestamp.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087733",
      "architecture": "x86_64"
    },
    {
      "severity": "error",
      "code": null,
      "path": "eclipse-cpp-2023-09-M2-macosx-cocoa-aarch64-6370600730443560226.dmg/Eclipse.app/Contents/Eclipse/plugins/com.github.jnr.jffi.native_1.3.11.jar/jni/Darwin/libjffi-1.2.jnilib",
      "message": "The binary is not signed with a valid Developer ID certificate.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087721",
      "architecture": "arm64"
    },
    {
      "severity": "error",
      "code": null,
      "path": "eclipse-cpp-2023-09-M2-macosx-cocoa-aarch64-6370600730443560226.dmg/Eclipse.app/Contents/Eclipse/plugins/com.github.jnr.jffi.native_1.3.11.jar/jni/Darwin/libjffi-1.2.jnilib",
      "message": "The signature does not include a secure timestamp.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087733",
      "architecture": "arm64"
    }
  ]
}
@jonahgraham
Copy link
Author

FYI: @akurtakov @merks

@merks
Copy link
Contributor

merks commented Aug 4, 2023

@akurtakov

I assume, but wanted to confirm, that if/when Orbit provides a version with signed libraries, that you will switch linuxtools to use that instead.

@akurtakov
Copy link

Sure will do

@merks
Copy link
Contributor

merks commented Aug 4, 2023

@jonahgraham

Looking in Orbit, I see these

image

I assume that this version, which is in the CDT, package is not also a problem:

image

@jonahgraham
Copy link
Author

I don't know why at the moment Apple isn't complaining about JNA's jnilibs. It has in the past, and may again in the future.

@merks
Copy link
Contributor

merks commented Aug 4, 2023

Maybe the jna ones are signed? Is there a way to tell?

These the the exact jars:

https://repo1.maven.org/maven2/com/github/jnr/jffi/1.3.11/jffi-1.3.11-native.jar
https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar

If the mac libraries aren't signed probably the Windows *.dll aren't signed as well, but maybe no one notices nor complains?

@jonahgraham
Copy link
Author

If they are signed I would be surprised because the JNA maintainers in the past said they are not interested in providing signed jnilibs in their release. I don't know how to test on a non-mac machine if they are signed, and I don't have a mac machine to check with.

If the mac libraries aren't signed probably the Windows *.dll aren't signed as well, but maybe no one notices nor complains?

Correct :-) The Apple notarization process makes us do it.

@merks
Copy link
Contributor

merks commented Aug 4, 2023

So it's probably better to plan ahead to avoid risk? If notarization suddenly fails late in a release cycle, that could put a damper on things. I think it will be especially important for these bundles not to be included in any features.

Also, if we are going to be modifying the jar's content, which is the entire point/goal here, I think we need to be careful not to use exactly the same (unqualified) version (or we need to use a different bundle symbolic name).

@akurtakov
Copy link

akurtakov commented Aug 4, 2023

https://openjdk.org/jeps/442 - as soon as it's no longer preview in some JVM version (hopefully 22) we should start using it and stop dealing with jni/jna/jnr .

@jonahgraham
Copy link
Author

So it's probably better to plan ahead to avoid risk?

Yes I agree. We have had some late failures in the past too since Apple is a moving target, e.g. m2e has (or had) an embedded jnilib that Hannes signed in the past eclipse-m2e/m2e-core#591

Notarization does not run on EPP for each build, but I (or you) can manually trigger it at anytime to see if there is a problem. Run https://ci.eclipse.org/packaging/job/notarize-downloads/ (but probably best disable https://ci.eclipse.org/packaging/job/simrel.epp-tycho-build/ so that the staging repo isn't changed while notarization is running). IIRC Notarization runs on Platform on each build.

@merks
Copy link
Contributor

merks commented Aug 4, 2023

https://openjdk.org/jeps/442 - as soon as it's no longer preview in some JVM version (hopefully 22) we should start using it and stop dealing with jni/jna/jnr .

It might be a case of getting everyone else to start using it too.

@akurtakov
Copy link

Well, from platform side doing core.net and equinox.security should free us from jna dependency. Which would be good first step.

merks added a commit that referenced this issue Aug 7, 2023
Add maven-sign to the orbit-aggregation

#7
@merks
Copy link
Contributor

merks commented Aug 7, 2023

The bundles with signed native libraries, including signed *.dll, are available here:

https://download.eclipse.org/tools/orbit/simrel/maven-sign/

They are also available in the aggregation:

https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/nightly/latest

In the current SimRel, these are the strict requirements on these two things.

image

image

Directly reusing com.sun.jna 5.13.0 as a Maven dependency is quite popular:

image

Only passage @ruspl-afed locks in that specific exact version.

@jonahgraham

How best do we ensure that we don't end up with the unsigned versions in the aggregation? I could add a rule to specifically exclude them, but we probably ought to get the contributing projects to use these signed versions instead...

It is possible to create an exclusion rule, though it's marked as an error when placed on a repository that doesn't contain a matching IU:

image

It would fail like this:

Cannot complete the install because some dependencies are not satisfiable
Software being installed: validationSet_main 1.0.0
Cannot satisfy dependency:
From: mappedRepo_download.eclipse.org_oomph_drops_milestone_S20230802-094623-1.30.0-M2 1.0.0
To: org.eclipse.equinox.p2.iu; mappedRepo_download.eclipse.org_oomph_drops_milestone_S20230802-094623-1.30.0-M2_rejections [1.0.0,1.0.0]
Cannot satisfy dependency:
From: mappedRepo_download.eclipse.org_oomph_drops_milestone_S20230802-094623-1.30.0-M2_rejections 1.0.0
To: org.eclipse.equinox.p2.iu; com.sun.jna [5.13.0,5.13.0]
Cannot satisfy dependency:
From: mappedRepo_download.eclipse.org_passage_updates_milestone_2.9.0-M2_ldc 1.0.0
To: org.eclipse.equinox.p2.iu; org.eclipse.passage.ldc.feature.feature.group [2.9.0.v20230701-2026,2.9.0.v20230701-2026]
Cannot satisfy dependency:
From: Passage LDC 2.9.0.v20230701-2026 (org.eclipse.passage.ldc.feature.feature.group 2.9.0.v20230701-2026)
To: org.eclipse.equinox.p2.iu; org.eclipse.passage.lic.define.feature.feature.group [2.9.0.v20230701-2026,2.9.0.v20230701-2026]
Cannot satisfy dependency:
From: Passage LIC Define 2.9.0.v20230701-2026 (org.eclipse.passage.lic.define.feature.feature.group 2.9.0.v20230701-2026)
To: org.eclipse.equinox.p2.iu; org.eclipse.passage.lic.execute.feature.feature.group [2.9.0.v20230701-2026,2.9.0.v20230701-2026]
Cannot satisfy dependency:
From: Passage LIC Execute 2.9.0.v20230701-2026 (org.eclipse.passage.lic.execute.feature.feature.group 2.9.0.v20230701-2026)
To: org.eclipse.equinox.p2.iu; org.eclipse.passage.lic.oshi.feature.feature.group [2.9.0.v20230701-2026,2.9.0.v20230701-2026]
Cannot satisfy dependency:
From: Passage LIC OSHI 2.9.0.v20230701-2026 (org.eclipse.passage.lic.oshi.feature.feature.group 2.9.0.v20230701-2026)
To: org.eclipse.equinox.p2.iu; com.sun.jna [5.13.0,5.13.0]
Cannot satisfy dependency:
From: validationSet_main 1.0.0
To: org.eclipse.equinox.p2.iu; mappedRepo_download.eclipse.org_oomph_drops_milestone_S20230802-094623-1.30.0-M2 [1.0.0,1.0.0]
Cannot satisfy dependency:
From: validationSet_main 1.0.0
To: org.eclipse.equinox.p2.iu; mappedRepo_download.eclipse.org_passage_updates_milestone_2.9.0-M2_ldc [1.0.0,1.0.0]

@akurtakov
Copy link

@merks Is everything ready to switch Linux Tools to signed jffi ?

@merks
Copy link
Contributor

merks commented Aug 7, 2023

Yes, both nightly builds (maven-sign and orbit-aggregation) contain the new IU with a qualifier:

image

akurtakov added a commit to akurtakov/org.eclipse.linuxtools that referenced this issue Aug 7, 2023
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
akurtakov added a commit to akurtakov/org.eclipse.linuxtools that referenced this issue Aug 7, 2023
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
@jonahgraham
Copy link
Author

@jonahgraham

How best do we ensure that we don't end up with the unsigned versions in the aggregation? I could add a rule to specifically exclude them, but we probably ought to get the contributing projects to use these signed versions instead...

It is possible to create an exclusion rule, though it's marked as an error when placed on a repository that doesn't contain a matching IU:

@merks I assume with @akurtakov updating Linux Tools and you adding exclusion rule we'll have the correct version in SimRel soon? If so, we can try to notarize the nightly build of EPP.

@merks
Copy link
Contributor

merks commented Aug 7, 2023

With this change

https://git.eclipse.org/r/c/simrel/org.eclipse.simrel.build/+/203578

I've contributed (temporarily) both new bundles to SimRel aggregation. The new jffi.native version is the only one in the aggregation:

image

So once the aggregation completes

https://ci.eclipse.org/simrel/job/simrel.runaggregator.pipeline/

you can test if notarization works.

Until passage doesn't lock in the unqualified version of com.sun.jna, we can't do much about that, but the newer version is there:

image

@jonahgraham
Copy link
Author

Thanks Ed. EPP build is running, when done I will try to notarize it and report back,

akurtakov added a commit to akurtakov/org.eclipse.linuxtools that referenced this issue Aug 7, 2023
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
Adjustments for everything to resolve properly with latest Orbit.
akurtakov added a commit to akurtakov/org.eclipse.linuxtools that referenced this issue Aug 7, 2023
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
Adjustments for everything to resolve properly with latest Orbit.
akurtakov added a commit to akurtakov/org.eclipse.linuxtools that referenced this issue Aug 7, 2023
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
Adjustments for everything to resolve properly with latest Orbit.
akurtakov added a commit to akurtakov/org.eclipse.linuxtools that referenced this issue Aug 7, 2023
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
Adjustments for everything to resolve properly with latest Orbit.
akurtakov added a commit to eclipse-linuxtools/org.eclipse.linuxtools that referenced this issue Aug 7, 2023
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
Adjustments for everything to resolve properly with latest Orbit.
@jonahgraham
Copy link
Author

Notarized successfully.

@jonahgraham
Copy link
Author

The new jffi exposes an issue. External Plug-in Libraries project that is auto-managed by JDT(?) has an error:

Cannot nest 'scratch/eclipse/src/cdt/workspace/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/com.github.jnr.jffi.native_1.3.11.v20230807-0900/jni' inside library 'scratch/eclipse/src/cdt/workspace/.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/com.github.jnr.jffi.native_1.3.11.v20230807-0900'

For some reason jffi appears as an unpacked bundle, perhaps due to Bundle-NativeCode not really sure?

@jonahgraham
Copy link
Author

Steps to reproduce last comment:

  1. Set target platform to something containing jffi
  2. "Add all plug-ins to java workspace scope" (from Ctrl-3)
  3. Observe error in Problems view:

image

Good thing is I found an easy workaround for now, right-click on the bundle in the plug-ins view and choose remove from java workspace scope:

image

@jonahgraham
Copy link
Author

I think what causes the issue is having Bundle-Classpath in the bundle be two directories which are nested:

Bundle-ClassPath: .,jni

Is this a JDT bug, or a JFFI bug?

@merks
Copy link
Contributor

merks commented Aug 9, 2023

The ebr version looked like this:

Archiver-Version                        Plexus Archiver
Automatic-Module-Name                   com.github.jnr.jffi.native
Build-Jdk-Spec                          11
Bundle-ClassPath                        .
                                        jni/
Bundle-Description                      Java Foreign Function Interface - Native Libraries
Bundle-License                          http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion                  2
Bundle-Name                             %bundleName
Bundle-SymbolicName                     com.github.jnr.jffi.native
Bundle-Vendor                           %bundleVendor
Bundle-Version                          1.3.9.v20221215-1656
Created-By                              Eclipse Bundle Recipe Maven Plug-in
Export-Package                          Darwin;version="1.3.9"
                                        aarch64-FreeBSD;version="1.3.9"
                                        aarch64-Linux;version="1.3.9"
                                        arm-Linux;version="1.3.9"
                                        i386-Linux;version="1.3.9"
                                        i386-SunOS;version="1.3.9"
                                        i386-Windows;version="1.3.9"
                                        mips64el-Linux;version="1.3.9"
                                        ppc-AIX;version="1.3.9"
                                        ppc64-AIX;version="1.3.9"
                                        ppc64-Linux;version="1.3.9"
                                        ppc64le-Linux;version="1.3.9"
                                        s390x-Linux;version="1.3.9"
                                        sparcv9-Linux;version="1.3.9"
                                        sparcv9-SunOS;version="1.3.9"
                                        x86_64-DragonFlyBSD;version="1.3.9"
                                        x86_64-FreeBSD;version="1.3.9"
                                        x86_64-Linux;version="1.3.9"
                                        x86_64-OpenBSD;version="1.3.9"
                                        x86_64-SunOS;version="1.3.9"
                                        x86_64-Windows;version="1.3.9"
Fragment-Host                           com.github.jnr.jffi
Manifest-Version                        1.0
Originally-Created-By                   Apache Maven Bundle Plugin

The new version like this:

Archiver-Version                        Plexus Archiver
Automatic-Module-Name                   org.jnrproject.jffi.nativelibs
Bnd-LastModified                        1678551168976
Build-Jdk                               11.0.17
Built-By                                headius
Bundle-ClassPath                        .
                                        jni
Bundle-Description                      Java Foreign Function Interface - Native Libraries
Bundle-License                          http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion                  2
Bundle-Name                             jffi
Bundle-SymbolicName                     com.github.jnr.jffi.native
Bundle-Version                          1.3.11.v20230807-0900
Created-By                              Apache Maven Bundle Plugin
Fragment-Host                           com.github.jnr.jffi
Manifest-Version                        1.0
Require-Bundle                          com.github.jnr.jffi
Tool                                    Bnd-2.1.0.20130426-122213

The ebr versions exported packages look kind of bogus, given these can't even be package names.

The only classpath difference is the / on the jni. I think the MANIFEST.MF must also be on the classpath, so I don't think it's wrong the way it is.

But I could modify the recipe to add the /?

@merks
Copy link
Contributor

merks commented Aug 9, 2023

Oh, no, I can't change the recipe because this doesn't use a recipe. It's exactly like this in Maven central:

https://repo1.maven.org/maven2/com/github/jnr/jffi/1.3.11/jffi-1.3.11.jar

@merks
Copy link
Contributor

merks commented Aug 9, 2023

Perhaps I could change it because there is a post-processing step when the libraries are being signed, but it's no clear why the / would make JDT happy/happier...

@akurtakov
Copy link

Is this one done or there is still some problem that I have to look at ?

merks added a commit to merks/eclipse.platform.releng.aggregator that referenced this issue Aug 15, 2023
eclipse-platform#1197
eclipse-platform#1199

Use version of com.sun.jna with signed libraries:

eclipse-orbit/orbit-simrel#7

Update net.bytebuddy to 1.14.6
merks added a commit to merks/eclipse.platform.releng.aggregator that referenced this issue Aug 15, 2023
eclipse-platform#1197
eclipse-platform#1199

Use version of com.sun.jna with signed libraries:

eclipse-orbit/orbit-simrel#7

Update net.bytebuddy to 1.14.6
merks added a commit to eclipse-platform/eclipse.platform.releng.aggregator that referenced this issue Aug 15, 2023
#1197
#1199

Use version of com.sun.jna with signed libraries:

eclipse-orbit/orbit-simrel#7

Update net.bytebuddy to 1.14.6
@merks
Copy link
Contributor

merks commented Aug 17, 2023

I think we are done here now.

@merks merks closed this as completed Aug 17, 2023
jjohnstn pushed a commit to jjohnstn/org.eclipse.linuxtools that referenced this issue Aug 29, 2024
Orbit signs the native libs to get MacOS notarization succeed.
See eclipse-orbit/orbit-simrel#7 for details.
Adjustments for everything to resolve properly with latest Orbit.
@DanielZanchi
Copy link

DanielZanchi commented Feb 4, 2025

I am having the same problem with a non sandboxed java app that is using JNA 5.10.
This is part of my ant script to create and sign the dmg:
ant script.txt

after i run the notarize command:

xcrun notarytool

that fails with this output:
{
  "logFormatVersion": 1,
  "jobId": "a2bee5b4-ee40-46fb-be7f-38d2c1c0a456",
  "status": "Invalid",
  "statusSummary": "Archive contains critical validation errors",
  "statusCode": 4000,
  "archiveFilename": "app-name-7.5.4-macosx.dmg",
  "uploadDate": "2025-02-04T16:06:22.286Z",
  "sha256": "425f94928ca7b009ec3f91abf01e54c6d4c2a0749bea40c1855dcc6aa17e96cc",
  "ticketContents": null,
  "issues": [
    {
      "severity": "error",
      "code": null,
      "path": "app-name-7.5.4-macosx.dmg/app-name.app/Contents/app/jna-5.10.0.jar/com/sun/jna/darwin-aarch64/libjnidispatch.jnilib",
      "message": "The binary is not signed with a valid Developer ID certificate.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087721",
      "architecture": "arm64"
    },
    {
      "severity": "error",
      "code": null,
      "path": "app-name-7.5.4-macosx.dmg/app-name.app/Contents/app/jna-5.10.0.jar/com/sun/jna/darwin-aarch64/libjnidispatch.jnilib",
      "message": "The signature does not include a secure timestamp.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087733",
      "architecture": "arm64"
    },
    {
      "severity": "error",
      "code": null,
      "path": "app-name-7.5.4-macosx.dmg/app-name.app/Contents/app/jna-5.10.0.jar/com/sun/jna/darwin-x86-64/libjnidispatch.jnilib",
      "message": "The binary is not signed.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087721",
      "architecture": "x86_64"
    },
    {
      "severity": "error",
      "code": null,
      "path": "app-name-7.5.4-macosx.dmg/app-name.app/Contents/app/jna-5.10.0.jar/com/sun/jna/darwin-x86-64/libjnidispatch.jnilib",
      "message": "The signature does not include a secure timestamp.",
      "docUrl": "https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues#3087733",
      "architecture": "x86_64"
    }
  ]
}

@jonahgraham
Copy link
Author

@DanielZanchi macOS notarization can be a bit of a whack-a-mole game as items that used to notarize suddenly stop as Apple adds more and more checks.

Thanks for the heads-up. Eclipse signing and notarization is working fine at the moment (from Jan 30):

{
"path": "eclipse-committers-2025-03-M2-macosx-cocoa-x86_64-7775373886969142494.dmg/Eclipse.app/Contents/Eclipse/plugins/com.sun.jna_5.16.0.v20241222-1200/com/sun/jna/darwin-x86-64/libjnidispatch.jnilib",
"digestAlgorithm": "SHA-256",
"cdhash": "8984888b12326f8617ba5b36d522cb039b11c455",
"arch": "x86_64"
},

(full log)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants