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

8326447: jpackage creates Windows installers that cannot be signed #23732

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alexeysemenyukoracle
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle commented Feb 22, 2025

Support the use of a custom msi wrapper executable when building an exe installer.

Put installer.exe file in the resource directory and jpackage will use it instead of the default msiwrapper.exe resource for exe installer.

To test this feature created a test that builds exe installer with a custom icon. The result installer exe is used as a custom msi wrapper executable in the second jpackage command that builds exe installer with the default icon. The installer exe produced by the second jackage command should have the same icon as the exe installer created in the first jpackage run.

Moved code verifying icons in executables from LauncherIconVerifier.WinIconVerifier class into WinExecutableIconVerifier class to make it available for tests. Replaced inline powershell script extracting icons from executables with standalone read-executable-icon.ps1 powershell script. The script uses ExtractIcon instead of ExtractAssociatedIcon. It extracts icon from the executable's resources and will not fall back to anything if there is no icon resource.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Warning

 ⚠️ Found leading lowercase letter in issue title for 8326447: jpackage creates Windows installers that cannot be signed

Issue

  • JDK-8326447: jpackage creates Windows installers that cannot be signed (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23732/head:pull/23732
$ git checkout pull/23732

Update a local copy of the PR:
$ git checkout pull/23732
$ git pull https://git.openjdk.org/jdk.git pull/23732/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23732

View PR using the GUI difftool:
$ git pr show -t 23732

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23732.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 22, 2025

👋 Welcome back asemenyuk! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 22, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 22, 2025
@openjdk
Copy link

openjdk bot commented Feb 22, 2025

@alexeysemenyukoracle The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Feb 22, 2025

Webrevs

…oesn't rely on GetLastError() to deliver error information to the caller. GetLastError() is not reliable in managed code.
@alexeysemenyukoracle
Copy link
Member Author

@sashamatveev PTAL

@sashamatveev
Copy link
Member

How user should figure out what installer.exe suppose to do? Should user just take it from another JDK which works? It does not look like a solution to this issue.

@sashamatveev
Copy link
Member

Can we add test which will use SignTool to sign produced .exe installer? This test can be similar to our macOS signing tests which require additional system configuration.

@alexeysemenyukoracle
Copy link
Member Author

alexeysemenyukoracle commented Feb 22, 2025

Should user just take it from another JDK which works?

Yes

It does not look like a solution to this issue.

Do you have a better idea?

@alexeysemenyukoracle
Copy link
Member Author

alexeysemenyukoracle commented Feb 22, 2025

Can we add test which will use SignTool to sign produced .exe installer?

What would be the action if the test fails? Why SignTool?

Other tools are:

Should we test that the installer exe is signable by specific versions of all these tools?

@sashamatveev
Copy link
Member

Do you have a better idea?

Can we sign msiwrapper.exe which does not have any embedded msi? jmod.exe can be used to extract it from resources. If it works maybe bug in our embed code. If it does not work do we know when it was introduced and figure out root cause?

@alexeysemenyukoracle
Copy link
Member Author

alexeysemenyukoracle commented Feb 22, 2025

maybe bug in our embed code

The code has been the same since the first release of jpackage.

do we know when it was introduced and figure out root cause

Quote from the bug description:

JDK 21.0.2 (Temurin)

A DESCRIPTION OF THE PROBLEM :
I have recently upgraded from Java 18 to Java 21, and noticed that there has been a change in jpackage which is causing signtool (the Microsoft code signing tool) to fail when signing the installer. Even though the installer .exe can be run on the system, the signtool command fails with:

SignTool Error: SignedCode::Sign returned error: 0x800700C1

This rather cryptic message refers to ERROR_BAD_EXE_FORMAT. Note that the same build run with Java 18 produces an .exe installer which does not have this problem.

If I compare the .exe produced by Java 21 with that produced by Java 18 with dumpfile and pestudio, I notice two differences:

  1. There is a 'version' section containing application name and version information in the Java 18 installer which is no longer present
  2. The linker version has changed from 1.27 to 1.37

Maybe something is off with the toolchain used to assemble Temurin JDK 21.

I used pestudio to inspect the value of the linker's version in PE headers of Open JDK binaries from Oracle. A few releases I inspected have something like "Microsoft Linker 14.36".
I did the same for msiwrapper.exe from Temurin JDK21 (OpenJDK21U-jdk_x64_windows_hotspot_21.0.2_13.zip). The linker version is "Microsoft Linker 14.37". For Temurin JDK18 (OpenJDK18U-jdk_x64_windows_hotspot_18.0.2.1_1.zip) the linker version is "Microsoft Linker 14.27".

  1. The linker version has changed from 1.27 to 1.37

Maybe the submitter meant the linker version changed from 14.27 to 14.37?

Anyway, they didn't complain about the Oracle variant of OpenJDK. If this is linker version-specific issue SignTool test may pass with Oracle OpenJDK and fail with other variants built with different toolchains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants