8373833: "error.cert.not.found" and "error.explicit-sign-no-cert" errors duplicate each other

Reviewed-by: almatvee
This commit is contained in:
Alexey Semenyuk 2026-01-06 23:56:59 +00:00
parent 7c979c1487
commit 6b3c1e0f78
3 changed files with 7 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -40,6 +40,7 @@ import javax.naming.ldap.Rdn;
import javax.security.auth.x500.X500Principal;
import jdk.jpackage.internal.MacCertificateUtils.CertificateHash;
import jdk.jpackage.internal.model.ConfigException;
import jdk.jpackage.internal.model.JPackageException;
import jdk.jpackage.internal.model.SigningIdentity;
final class SigningIdentityBuilder {
@ -147,11 +148,9 @@ final class SigningIdentityBuilder {
Objects.requireNonNull(keychain);
switch (certs.size()) {
case 0 -> {
var errMsg = I18N.format("error.cert.not.found", certificateSelector.signingIdentities().getFirst(),
keychain.map(Keychain::name).orElse(""));
Log.error(I18N.format("message.error-header", errMsg));
throw I18N.buildConfigException("error.explicit-sign-no-cert")
.advice("error.explicit-sign-no-cert.advice").create();
throw new JPackageException(I18N.format("error.cert.not.found",
certificateSelector.signingIdentities().getFirst(),
keychain.map(Keychain::name).orElse("")));
}
case 1 -> {
return certs.getFirst();

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -24,8 +24,6 @@
#
#
error.invalid-cfbundle-version.advice=Set a compatible 'app-version' value. Valid versions are one to three integers separated by dots.
error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found
error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain
error.certificate.expired=Certificate expired {0}
error.cert.not.found=No certificate found matching [{0}] using keychain [{1}]
error.multiple.certs.found=Multiple certificates matching name [{0}] found in keychain [{1}]

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -707,12 +707,6 @@ public final class ErrorTest {
final List<CannedFormattedString> errorMessages = new ArrayList<>();
errorMessages.add(makeError(JPackageStringBundle.MAIN.cannedFormattedString(
"error.cert.not.found", "Developer ID Application: " + signingId, "")));
errorMessages.addAll(Stream.of(
Map.<String, UnaryOperator<CannedFormattedString>>entry("error.explicit-sign-no-cert", JPackageCommand::makeError),
Map.<String, UnaryOperator<CannedFormattedString>>entry("error.explicit-sign-no-cert.advice", JPackageCommand::makeAdvice)
).map(e -> {
return e.getValue().apply(JPackageStringBundle.MAIN.cannedFormattedString(e.getKey()));
}).toList());
final var cmd = JPackageCommand.helloAppImage()
.ignoreDefaultVerbose(true)