diff --git a/dist/setup/index.js b/dist/setup/index.js index 891909d9..2ab75543 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -11093,17 +11093,24 @@ function setupMaven(opts) { const p12Path = path.join(certDir, 'certificate.p12'); fs.writeFileSync(p12Path, Buffer.from(opts.keystore, 'base64')); core.exportVariable('MAVEN_OPTS', `-Djavax.net.ssl.keyStore=${p12Path} -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=${opts.password}`); - yield exec.exec(path.join(opts.javaPath, 'bin/keytool'), [ - '-importcert', - '-cacerts', - '-storepass', - 'changeit', - '-noprompt', - '-alias', - 'mycert', - '-file', - rooCaPath - ]); + try { + yield exec.exec(path.join(opts.javaPath, 'bin/keytool'), [ + '-importcert', + '-cacerts', + '-storepass', + 'changeit', + '-noprompt', + '-alias', + 'mycert', + '-file', + rooCaPath + ]); + } + catch (e) { + if (!e.message.includes('already exists')) { + throw e; + } + } core.debug(`added maven opts for MTLS access`); }); } diff --git a/src/maven.ts b/src/maven.ts index 1cab5dc0..e1da4cc7 100644 --- a/src/maven.ts +++ b/src/maven.ts @@ -65,17 +65,23 @@ export async function setupMaven(opts: MavenOpts): Promise { `-Djavax.net.ssl.keyStore=${p12Path} -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=${opts.password}` ); - await exec.exec(path.join(opts.javaPath, 'bin/keytool'), [ - '-importcert', - '-cacerts', - '-storepass', - 'changeit', - '-noprompt', - '-alias', - 'mycert', - '-file', - rooCaPath - ]); + try { + await exec.exec(path.join(opts.javaPath, 'bin/keytool'), [ + '-importcert', + '-cacerts', + '-storepass', + 'changeit', + '-noprompt', + '-alias', + 'mycert', + '-file', + rooCaPath + ]); + } catch (e) { + if (!(e as Error).message.includes('already exists')) { + throw e; + } + } core.debug(`added maven opts for MTLS access`); }