openjdk-17-jre-headless:arm64 Package ca-certificates-java is not configured yet

Bug #2019908 reported by Eswar
86
This bug affects 14 people
Affects Status Importance Assigned to Milestone
ca-certificates-java (Ubuntu)
Fix Released
Undecided
Vladimir Petko

Bug Description

[Impact]

Due to OpenJDK changes[1] it is impossible to install JRE 17 in supported releases below Lunar (Kinetic, Jammy, Focal, Bionic) on amd64, arm64 platform due to the configuration order (see comment)

A system with a pre-installed default JRE (e.g. JRE 11 in Jammy) is not affected.

[Suggested Fix]

Immediate fix:
 - copy java.security.dpkg-new to java.security if .dpkg-new file is present but java.security is not.

Long term fix:
Backport
 - https://code.launchpad.net/~vpa1977/ubuntu/+source/ca-certificates-java/+git/ca-certificates-java/+merge/438150

This merge proposal:
 - removes dependency on JRE
 - fixes command line for keytool call
 - add autopkgtests

[Test Plan]

 - autopkgtests must pass for all platforms
 - Test package install in lxc container and ensure that race condition is reproduced for each release - ca-certificates java are configured before openjdk

----------------------cut------------------------------------
for release in bionic focal jammy kinetic; do
    echo !!!!!!!!!!!!!!${release}!!!!!!!!!!!!!!!!!!!!
    lxc launch images:ubuntu/${release} lp2019908
    lxc exec lp2019908 -- apt install software-properties-common
    lxc exec lp2019908 -- add-apt-repository ppa:vpa1977/ca-certificates-java-patch
    lxc exec lp2019908 -- apt-get update
    lxc exec lp2019908 -- apt-get -y install openjdk-17-jre-headless
    lxc stop lp2019908
    lxc delete lp2019908
    echo !!!!!!TEST DONE for ${release}!!!!!!!!!
done
----------------------cut------------------------------------

[Where problems could occur]

 The fix copies java.security but do not touch other files.
 While this release can be tested, we are not protected from similiar regressions.

[Original report]

From May-16 below is failing:
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \
    openjdk-17-jre-headless

#7 111.8 head: cannot open '/etc/ssl/certs/java/cacerts' for reading: No such file or directory
#7 111.9 Exception in thread "main" java.lang.InternalError: Error loading java.security file
#7 111.9 at java.base/java.security.Security.initialize(Security.java:106)
#7 111.9 at java.base/java.security.Security$1.run(Security.java:84)
#7 111.9 at java.base/java.security.Security$1.run(Security.java:82)
#7 111.9 at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
#7 111.9 at java.base/java.security.Security.<clinit>(Security.java:82)
#7 111.9 at java.base/sun.security.jca.ProviderList.<init>(ProviderList.java:178)
#7 111.9 at java.base/sun.security.jca.ProviderList$2.run(ProviderList.java:96)
#7 111.9 at java.base/sun.security.jca.ProviderList$2.run(ProviderList.java:94)
#7 111.9 at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
#7 111.9 at java.base/sun.security.jca.ProviderList.fromSecurityProperties(ProviderList.java:93)
#7 111.9 at java.base/sun.security.jca.Providers.<clinit>(Providers.java:55)
#7 111.9 at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:156)
#7 111.9 at java.base/java.security.cert.CertificateFactory.getInstance(CertificateFactory.java:193)
#7 111.9 at org.debian.security.KeyStoreHandler.<init>(KeyStoreHandler.java:50)
#7 111.9 at org.debian.security.UpdateCertificates.<init>(UpdateCertificates.java:65)
#7 111.9 at org.debian.security.UpdateCertificates.main(UpdateCertificates.java:51)
#7 111.9 dpkg: error processing package ca-certificates-java (--configure):
#7 111.9 installed ca-certificates-java package post-installation script subprocess returned error exit status 1
#7 111.9 dpkg: dependency problems prevent configuration of openjdk-17-jre-headless:arm64:
#7 111.9 openjdk-17-jre-headless:arm64 depends on ca-certificates-java (>= 20190405~); however:
#7 111.9 Package ca-certificates-java is not configured yet.
#7 111.9
#7 111.9 dpkg: error processing package openjdk-17-jre-headless:arm64 (--configure):
#7 111.9 dependency problems - leaving unconfigured
#7 111.9 Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
#7 111.9 Processing triggers for ca-certificates (20211016ubuntu0.22.04.1) ...
#7 111.9 Updating certificates in /etc/ssl/certs...
#7 112.2 0 added, 0 removed; done.
#7 112.2 Running hooks in /etc/ca-certificates/update.d...
#7 112.2
#7 112.2 Exception in thread "main" java.lang.InternalError: Error loading java.security file
#7 112.2 at java.base/java.security.Security.initialize(Security.java:106)
#7 112.2 at java.base/java.security.Security$1.run(Security.java:84)
#7 112.2 at java.base/java.security.Security$1.run(Security.java:82)
#7 112.2 at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
#7 112.2 at java.base/java.security.Security.<clinit>(Security.java:82)
#7 112.2 at java.base/sun.security.jca.ProviderList.<init>(ProviderList.java:178)
#7 112.2 at java.base/sun.security.jca.ProviderList$2.run(ProviderList.java:96)
#7 112.2 at java.base/sun.security.jca.ProviderList$2.run(ProviderList.java:94)
#7 112.2 at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
#7 112.2 at java.base/sun.security.jca.ProviderList.fromSecurityProperties(ProviderList.java:93)
#7 112.2 at java.base/sun.security.jca.Providers.<clinit>(Providers.java:55)
#7 112.2 at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:156)
#7 112.2 at java.base/java.security.cert.CertificateFactory.getInstance(CertificateFactory.java:193)
#7 112.2 at org.debian.security.KeyStoreHandler.<init>(KeyStoreHandler.java:50)
#7 112.2 at org.debian.security.UpdateCertificates.<init>(UpdateCertificates.java:65)
#7 112.2 at org.debian.security.UpdateCertificates.main(UpdateCertificates.java:51)
#7 112.2 E: /etc/ca-certificates/update.d/jks-keystore exited with code 1.
#7 112.2 done.
#7 112.3 Errors were encountered while processing:
#7 112.3 ca-certificates-java
#7 112.3 openjdk-17-jre-headless:arm64
#7 112.3 E: Sub-process /usr/bin/dpkg returned an error code (1)

========================

looks like packages are updated on May-16 http://security.ubuntu.com/ubuntu/pool/universe/o/openjdk-17/
and its causing issues

[1] https://github.com/openjdk/jdk17u/commit/4be52ee572e4fd65f2ac66d5e78c711c8eb6a61e#diff-4d6411695be3dc177d5f0e85c5051c7cfca24c54e22518281b7d26fd858d1893

Tags: patch fr-4364
Revision history for this message
Vladimir Petko (vpa1977) wrote (last edit ):

The failure is caused by the order of package configuration:
 - openjdk-17 is unpacked but properties files still have dpkg_new extensions
 - ca-certificates-java tries to run postinstallation script which requires a working java.
 - openjdk 17 now requires java.security file present (presently it was silently ignoring it) to intialise Security.

See:
- https://bugs.launchpad.net/ubuntu/+source/ca-certificates-java/+bug/2003822

I will discuss today and convert this one or LP: #2003750 to SRU format to deploy the fix.

tags: added: fr-4364
Revision history for this message
Vladimir Petko (vpa1977) wrote :
Download full text (8.4 KiB)

Note: amd64 installs fine:

 sudo DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \
    openjdk-17-jre-headless
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libflashrom1 libftdi1-2 libmozjs-91-0 linux-headers-5.19.0-32-generic
  linux-hwe-5.19-headers-5.19.0-32 linux-image-5.19.0-32-generic
  linux-modules-5.19.0-32-generic linux-modules-extra-5.19.0-32-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  ca-certificates-java
Suggested packages:
  fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho
  fonts-wqy-microhei | fonts-wqy-zenhei
The following NEW packages will be installed:
  ca-certificates-java openjdk-17-jre-headless
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 48.3 MB of archives.
After this operation, 193 MB of additional disk space will be used.
Get:1 http://nz.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 openjdk-17-jre-headless amd64 17.0.7+7~us1-0ubuntu1~22.04.2 [48.3 MB]
Get:2 http://nz.archive.ubuntu.com/ubuntu jammy-updates/main amd64 ca-certificates-java all 20190909ubuntu1.1 [12.0 kB]
Fetched 48.3 MB in 1s (32.7 MB/s)
Selecting previously unselected package openjdk-17-jre-headless:amd64.
(Reading database ... 244863 files and directories currently installed.)
Preparing to unpack .../openjdk-17-jre-headless_17.0.7+7~us1-0ubuntu1~22.04.2_amd64.deb ...
Unpacking openjdk-17-jre-headless:amd64 (17.0.7+7~us1-0ubuntu1~22.04.2) ...
Selecting previously unselected package ca-certificates-java.
Preparing to unpack .../ca-certificates-java_20190909ubuntu1.1_all.deb ...
Unpacking ca-certificates-java (20190909ubuntu1.1) ...
Setting up openjdk-17-jre-headless:amd64 (17.0.7+7~us1-0ubuntu1~22.04.2) ...
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/jpackage to provide /usr/bin/jpackage (jpackage) in auto mode
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode
Setting up ca-certificates-java (20190909ubuntu1.1) ...
head: cannot open '/etc/ssl/certs/java/cacerts' for reading: No such file or directory
Adding debian:Starfield_Services_Root_Certificate_Authority_-_G2.pem
Adding debian:Comodo_AAA_Services_root.pem
Adding debian:DigiCert_Global_Root_G2.pem
Adding debian:Entrust_Root_Certification_Authority_-_G4.pem
Adding debian:Trustwave_Global_Certification_Authority.pem
Adding debian:emSign_ECC_Root_CA_-_C3.pem
Adding debian:Trustwave_Global_ECC_P256_Certification_Authority.pem
Adding debian:Hellenic_Academic_and_Research_Institutions_RootCA_2015.pem
Adding debian:Entrust.net_Premium_2048_Secure_Server_CA.p...

Read more...

Vladimir Petko (vpa1977)
description: updated
description: updated
Changed in ca-certificates-java (Ubuntu):
assignee: nobody → Vladimir Petko (vpa1977)
Revision history for this message
Noorul Islam K M (noorul) wrote :

Shouldn't we set the importance in this case as this is blocking.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ca-certificates-java (Ubuntu):
status: New → Confirmed
Revision history for this message
Noorul Islam K M (noorul) wrote :
Download full text (17.1 KiB)

I see same issue while installing it in amd64 container. Here is the log

noorul@bangaram:~$ docker run --rm -it ubuntu:22.04
root@a67b38de09c6:/# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [490 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [108 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [901 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [36.3 kB]
Get:10 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [348 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages [1792 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [266 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1150 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [349 kB]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [42.2 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [769 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [49.4 kB]
Get:18 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [25.6 kB]
Fetched 24.5 MB in 20s (1194 kB/s)
Reading package lists... Done
root@a67b38de09c6:/# DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends openjdk-17-jre-headless
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ca-certificates ca-certificates-java fontconfig-config fonts-dejavu-core java-common libasound2 libasound2-data libavahi-client3 libavahi-common-data libavahi-common3
  libbrotli1 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgraphite2-3 libharfbuzz0b libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3
  libpcsclite1 libpng16-16 libsqlite3-0 openssl ucf
Suggested packages:
  default-jre libasound2-plugins alsa-utils cups-common liblcms2-utils pcscd libnss-mdns fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  | fonts-wqy-zenhei fonts-indic
Recommended packages:
  alsa-ucm-conf alsa-topology-conf dbus libglib2.0-data shared-mime-info xdg-user-dirs
The following NEW packages will be installed:
  ca-certificates ca-certificates-java fontconfig-config fonts-dejavu-core java-common libasound2 libasound2-data libavahi-client3 libavahi-common-data libavahi-common3
  libbrotli1 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgraphite2-3 libharfbuzz0b libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3
  libpcsclite1 libpng16-16 libsqlite3-0 openjdk-17-jre-headless openssl ucf
0 upgraded, 30 newly installed, 0 to remove an...

Vladimir Petko (vpa1977)
description: updated
Vladimir Petko (vpa1977)
description: updated
Revision history for this message
Noorul Islam K M (noorul) wrote :

I saw this issue occurring in amd64 docker image.

Revision history for this message
Vladimir Petko (vpa1977) wrote :
description: updated
Revision history for this message
Vladimir Petko (vpa1977) wrote :

Patch for ca-certificates-java in Jammy

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Patch for ca-certificates-java in kinetic

Revision history for this message
Vladimir Petko (vpa1977) wrote :

ca-certificates-java focal patch

Revision history for this message
Vladimir Petko (vpa1977) wrote :

ca-certificates-java bionic patch

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Install log for focal

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Install log for jammy

description: updated
description: updated
Revision history for this message
Vladimir Petko (vpa1977) wrote :

Install log for kinetic

Revision history for this message
Vladimir Petko (vpa1977) wrote (last edit ):

Reproduced bionic race condition in arm vm - see below:

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Bionic test log

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "ca-certificates-java-jammy.patch" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Revision history for this message
Steve Beattie (sbeattie) wrote :

Thanks for preparing the patches, Vladimir. I have prepared builds of them in the ubuntu-security-proposed ppa: https://launchpad.net/~ubuntu-security-proposed/+archive/ubuntu/ppa/+packages after tweaking the changelog and versions a bit. It would be great if interested people could do additional testing of the ca-certificates-java packages from there.

Please note that the ubuntu-security-proposed ppa is used for updates preparation and should not be left enabled on production systems. Thanks.

Changed in ca-certificates-java (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Vladimir Petko (vpa1977) wrote :

I have ran the test using the script below and can confirm that openjdk-17 installs from security ppa when ca-certificates-java are configured before openjdk for focal, jammy and kinetic.

I had trouble reproducing with bionic, will try to use arm vm again.

--------------------------cut----------------------------
for release in bionic focal jammy kinetic; do
    echo !!!!!!!!!!!!!!${release}!!!!!!!!!!!!!!!!!!!!
    lxc launch images:ubuntu/${release} lp2019908
    lxc exec lp2019908 -- apt install software-properties-common
    lxc exec lp2019908 -- add-apt-repository ppa:ubuntu-security-proposed/ppa
    lxc exec lp2019908 -- apt-get update
    echo apt-get -y install openjdk-17-jre-headless
    lxc exec lp2019908 -- apt-get -y install openjdk-17-jre-headless
    lxc exec lp2019908 -- ls -l /etc/java-17-openjdk/security
    lxc stop lp2019908
    lxc delete lp2019908
    echo !!!!!!TEST DONE for ${release}!!!!!!!!!
done
-------------------------------cut----------------------------------

Revision history for this message
Vladimir Petko (vpa1977) wrote (last edit ):

I have validated that installation works for bionic with the security ppa using the following docker file:
--------------------cut------------------
from ubuntu:bionic
RUN apt-get update && apt-get install --yes software-properties-common && add-apt-repository -y ppa:ubuntu-security-proposed/ppa
RUN \
    DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \
    openjdk-17-jre

-----------------------------------------

Notice jre, not jre-headless - I could not reproduce the issue installing headless.

Revision history for this message
Vladimir Petko (vpa1977) wrote :

Test upgrade for affected versions using the script below: no issues.

-------------------
for release in bionic focal jammy kinetic; do
    echo !!!!!!!!!!!!!!${release}!!!!!!!!!!!!!!!!!!!!
    lxc launch images:ubuntu/${release} lp2019908
    lxc exec lp2019908 -- apt install software-properties-common
    lxc exec lp2019908 -- apt-get -y install ca-certificates-java
    lxc exec lp2019908 -- add-apt-repository ppa:ubuntu-security-proposed/ppa
    lxc exec lp2019908 -- apt-get update
    echo -- upgrade ca-certificates-java start ---
    lxc exec lp2019908 -- apt-get upgrade
    lxc stop lp2019908
    lxc delete lp2019908
    echo !!!!!!TEST DONE for ${release}!!!!!!!!!
done
-------------------

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ca-certificates-java - 20220719ubuntu0.1

---------------
ca-certificates-java (20220719ubuntu0.1) kinetic-security; urgency=medium

  * REGRESSION UPDATE: ca-certificates-java can fail to install with
    openjdk-17 (LP: #2019908).
    - d/postinst, d/jks-keystore.hook: copy java.security for import tool
  * d/t/*: add autopkgtests.

 -- Vladimir Petko <email address hidden> Thu, 18 May 2023 08:39:52 +1200

Changed in ca-certificates-java (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ca-certificates-java - 20190909ubuntu1.2

---------------
ca-certificates-java (20190909ubuntu1.2) jammy-security; urgency=medium

  * REGRESSION UPDATE: ca-certificates-java can fail to install with
    openjdk-17 (LP: #2019908).
    - d/postinst, d/jks-keystore.hook: copy java.security for import tool
  * d/t/*: add autopkgtests.

 -- Vladimir Petko <email address hidden> Thu, 18 May 2023 08:09:10 +1200

Changed in ca-certificates-java (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ca-certificates-java - 20190405ubuntu1.1

---------------
ca-certificates-java (20190405ubuntu1.1) focal-security; urgency=medium

  * REGRESSION UPDATE: ca-certificates-java can fail to install with
    openjdk-17 (LP: #2019908).
    - d/postinst, d/jks-keystore.hook: copy java.security for import tool
    - d/postinst: Support locating Java 18-21. Use setup_path() from
      20220719. (LP: #1998065)
    - debian/jks-keystore.hook: Support locating Java 18-21 to avoid java
      not found message (LP: #1998065).
  * d/t/*: add autopkgtests.

 -- Vladimir Petko <email address hidden> Thu, 18 May 2023 09:11:05 +1200

Changed in ca-certificates-java (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.