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

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

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

View file

@ -76,18 +76,33 @@ export async function setupMaven(opts: MavenOpts): Promise<void> {
} }
try { try {
await exec.exec( const certexists = await exec.exec(
path.join(opts.javaPath, 'bin/keytool'), path.join(opts.javaPath, 'bin/keytool'),
params.concat([ [
'-list',
'-storepass', '-storepass',
'changeit', 'changeit',
'-noprompt', '-noprompt',
'-alias', '-alias',
'mycert', 'mycert',
'-file', '-keystore',
rootCaPath `${opts.javaPath}/jre/lib/security/cacerts`
]) ]
); );
if (certexists !== 0) {
await exec.exec(
path.join(opts.javaPath, 'bin/keytool'),
params.concat([
'-storepass',
'changeit',
'-noprompt',
'-alias',
'mycert',
'-file',
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}`);
} }