fix: check if cert is in keystore

when using the shared cache the cert is already in the keystore
This commit is contained in:
Soren Mathiasen 2021-11-12 12:32:25 +01:00
parent 9b706f9681
commit 4bd0bfb1af
No known key found for this signature in database
GPG key ID: 9B0D4DFDB7B1412F
2 changed files with 36 additions and 9 deletions

12
dist/setup/index.js generated vendored
View file

@ -11102,6 +11102,17 @@ function setupMaven(opts) {
params.push('-cacerts'); params.push('-cacerts');
} }
try { try {
const certexists = yield exec.exec(path.join(opts.javaPath, 'bin/keytool'), [
'-list',
'-storepass',
'changeit',
'-noprompt',
'-alias',
'mycert',
'-keystore',
`${opts.javaPath}/jre/lib/security/cacerts`
]);
if (certexists !== 0) {
yield exec.exec(path.join(opts.javaPath, 'bin/keytool'), params.concat([ yield exec.exec(path.join(opts.javaPath, 'bin/keytool'), params.concat([
'-storepass', '-storepass',
'changeit', 'changeit',
@ -11112,6 +11123,7 @@ function setupMaven(opts) {
rootCaPath rootCaPath
])); ]));
} }
}
catch (e) { catch (e) {
core.warning(`keytool return an error: ${e.message}`); core.warning(`keytool return an error: ${e.message}`);
} }

View file

@ -76,6 +76,20 @@ export async function setupMaven(opts: MavenOpts): Promise<void> {
} }
try { try {
const certexists = await exec.exec(
path.join(opts.javaPath, 'bin/keytool'),
[
'-list',
'-storepass',
'changeit',
'-noprompt',
'-alias',
'mycert',
'-keystore',
`${opts.javaPath}/jre/lib/security/cacerts`
]
);
if (certexists !== 0) {
await exec.exec( await exec.exec(
path.join(opts.javaPath, 'bin/keytool'), path.join(opts.javaPath, 'bin/keytool'),
params.concat([ params.concat([
@ -88,6 +102,7 @@ export async function setupMaven(opts: MavenOpts): Promise<void> {
rootCaPath rootCaPath
]) ])
); );
}
} catch (e) { } catch (e) {
core.warning(`keytool return an error: ${(e as Error).message}`); core.warning(`keytool return an error: ${(e as Error).message}`);
} }