Skip to content

Commit

Permalink
Disables loading certificates when NIK is used with Java 18+
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-david-osullivan committed Nov 29, 2022
1 parent 563c8ff commit caa4c97
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion jdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (j JDK) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
return libcnb.Layer{}, fmt.Errorf("unable to load certificates\n%w", err)
}
} else {
j.Logger.Bodyf("%s: The JVM cacerts entries cannot be loaded with Java 18, for more information see: https://github.com/paketo-buildpacks/libjvm/issues/158", color.YellowString("Warning"))
j.Logger.Bodyf("%s: The JVM cacerts entries cannot be loaded with Java 18+, for more information see: https://github.com/paketo-buildpacks/libjvm/issues/158", color.YellowString("Warning"))
}
return layer, nil
})
Expand Down
2 changes: 1 addition & 1 deletion jlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (j JLink) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
return libcnb.Layer{}, fmt.Errorf("unable to load certificates\n%w", err)
}
} else {
j.Logger.Bodyf("%s: The JVM cacerts entries cannot be loaded with Java 18, for more information see: https://github.com/paketo-buildpacks/libjvm/issues/158", color.YellowString("Warning"))
j.Logger.Bodyf("%s: The JVM cacerts entries cannot be loaded with Java 18+, for more information see: https://github.com/paketo-buildpacks/libjvm/issues/158", color.YellowString("Warning"))
}

if IsBuildContribution(j.Metadata) {
Expand Down
2 changes: 1 addition & 1 deletion jre.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (j JRE) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
return libcnb.Layer{}, fmt.Errorf("unable to load certificates\n%w", err)
}
} else {
j.Logger.Bodyf("%s: The JVM cacerts entries cannot be loaded with Java 18, for more information see: https://github.com/paketo-buildpacks/libjvm/issues/158", color.YellowString("Warning"))
j.Logger.Bodyf("%s: The JVM cacerts entries cannot be loaded with Java 18+, for more information see: https://github.com/paketo-buildpacks/libjvm/issues/158", color.YellowString("Warning"))
}

if IsBuildContribution(j.Metadata) {
Expand Down
8 changes: 6 additions & 2 deletions nik.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ func (n NIK) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
return libcnb.Layer{}, fmt.Errorf("unable to set keystore file permissions\n%w", err)
}

if err := n.CertificateLoader.Load(keyStorePath, "changeit"); err != nil {
return libcnb.Layer{}, fmt.Errorf("unable to load certificates\n%w", err)
if IsBeforeJava18(n.JDKDependency.Version) {
if err := n.CertificateLoader.Load(keyStorePath, "changeit"); err != nil {
return libcnb.Layer{}, fmt.Errorf("unable to load certificates\n%w", err)
}
} else {
n.Logger.Bodyf("%s: The JVM cacerts entries cannot be loaded with Java 18+, for more information see: https://github.com/paketo-buildpacks/libjvm/issues/158", color.YellowString("Warning"))
}

if n.NativeDependency != nil {
Expand Down

0 comments on commit caa4c97

Please sign in to comment.