mirror of
https://github.com/actions/setup-java.git
synced 2025-03-13 17:47:03 +00:00
Merge pull request #8 from Tradeshift/support-java-8
Add cacert rule for java 8
This commit is contained in:
commit
9b706f9681
4 changed files with 42 additions and 22 deletions
1
CODEOWNERS
Normal file
1
CODEOWNERS
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* @Tradeshift/developer-productivity
|
23
dist/setup/index.js
generated
vendored
23
dist/setup/index.js
generated
vendored
|
@ -11084,27 +11084,33 @@ function setupMaven(opts) {
|
||||||
flag: 'w'
|
flag: 'w'
|
||||||
});
|
});
|
||||||
const certDir = path.join(os.homedir(), 'certs');
|
const certDir = path.join(os.homedir(), 'certs');
|
||||||
const rooCaPath = path.join(certDir, 'rootca.crt');
|
const rootCaPath = path.join(certDir, 'rootca.crt');
|
||||||
yield io.mkdirP(certDir);
|
yield io.mkdirP(certDir);
|
||||||
fs.writeFileSync(rooCaPath, btoa(opts.caCert), {
|
fs.writeFileSync(rootCaPath, btoa(opts.caCert), {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
flag: 'w'
|
flag: 'w'
|
||||||
});
|
});
|
||||||
const p12Path = path.join(certDir, 'certificate.p12');
|
const p12Path = path.join(certDir, 'certificate.p12');
|
||||||
fs.writeFileSync(p12Path, Buffer.from(opts.keystore, 'base64'));
|
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}`);
|
core.exportVariable('MAVEN_OPTS', `-Djavax.net.ssl.keyStore=${p12Path} -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=${opts.password}`);
|
||||||
|
var params = ['-importcert'];
|
||||||
|
// keytool for JAVA 8 has different API
|
||||||
|
if (opts.javaVersion === '8') {
|
||||||
|
params.push('-keystore', `${opts.javaPath}/jre/lib/security/cacerts`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
params.push('-cacerts');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
yield exec.exec(path.join(opts.javaPath, 'bin/keytool'), [
|
yield exec.exec(path.join(opts.javaPath, 'bin/keytool'), params.concat([
|
||||||
'-importcert',
|
|
||||||
'-cacerts',
|
|
||||||
'-storepass',
|
'-storepass',
|
||||||
'changeit',
|
'changeit',
|
||||||
'-noprompt',
|
'-noprompt',
|
||||||
'-alias',
|
'-alias',
|
||||||
'mycert',
|
'mycert',
|
||||||
'-file',
|
'-file',
|
||||||
rooCaPath
|
rootCaPath
|
||||||
]);
|
]));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.warning(`keytool return an error: ${e.message}`);
|
core.warning(`keytool return an error: ${e.message}`);
|
||||||
|
@ -33373,7 +33379,8 @@ function run() {
|
||||||
password: core.getInput(constants.INPUT_MAVEN_KEYSTORE_PASSWORD),
|
password: core.getInput(constants.INPUT_MAVEN_KEYSTORE_PASSWORD),
|
||||||
settings: core.getInput(constants.INPUT_MAVEN_SETTINGS_B64),
|
settings: core.getInput(constants.INPUT_MAVEN_SETTINGS_B64),
|
||||||
securitySettings: core.getInput(constants.INPUT_MAVEN_SECURITY_SETTINGS_B64),
|
securitySettings: core.getInput(constants.INPUT_MAVEN_SECURITY_SETTINGS_B64),
|
||||||
javaPath: ''
|
javaPath: '',
|
||||||
|
javaVersion: version
|
||||||
};
|
};
|
||||||
const mvnVersion = core.getInput(constants.INPUT_MAVEN_VERSION);
|
const mvnVersion = core.getInput(constants.INPUT_MAVEN_VERSION);
|
||||||
const arch = core.getInput(constants.INPUT_ARCHITECTURE, { required: true });
|
const arch = core.getInput(constants.INPUT_ARCHITECTURE, { required: true });
|
||||||
|
|
37
src/maven.ts
37
src/maven.ts
|
@ -13,6 +13,7 @@ export interface MavenOpts {
|
||||||
settings: string;
|
settings: string;
|
||||||
securitySettings: string;
|
securitySettings: string;
|
||||||
javaPath: string;
|
javaPath: string;
|
||||||
|
javaVersion: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isValidOptions(mvnOpts: MavenOpts): boolean {
|
export function isValidOptions(mvnOpts: MavenOpts): boolean {
|
||||||
|
@ -50,9 +51,9 @@ export async function setupMaven(opts: MavenOpts): Promise<void> {
|
||||||
);
|
);
|
||||||
|
|
||||||
const certDir = path.join(os.homedir(), 'certs');
|
const certDir = path.join(os.homedir(), 'certs');
|
||||||
const rooCaPath = path.join(certDir, 'rootca.crt');
|
const rootCaPath = path.join(certDir, 'rootca.crt');
|
||||||
await io.mkdirP(certDir);
|
await io.mkdirP(certDir);
|
||||||
fs.writeFileSync(rooCaPath, btoa(opts.caCert), {
|
fs.writeFileSync(rootCaPath, btoa(opts.caCert), {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
flag: 'w'
|
flag: 'w'
|
||||||
});
|
});
|
||||||
|
@ -65,18 +66,28 @@ export async function setupMaven(opts: MavenOpts): Promise<void> {
|
||||||
`-Djavax.net.ssl.keyStore=${p12Path} -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=${opts.password}`
|
`-Djavax.net.ssl.keyStore=${p12Path} -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=${opts.password}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var params: string[] = ['-importcert'];
|
||||||
|
|
||||||
|
// keytool for JAVA 8 has different API
|
||||||
|
if (opts.javaVersion === '8') {
|
||||||
|
params.push('-keystore', `${opts.javaPath}/jre/lib/security/cacerts`);
|
||||||
|
} else {
|
||||||
|
params.push('-cacerts');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await exec.exec(path.join(opts.javaPath, 'bin/keytool'), [
|
await exec.exec(
|
||||||
'-importcert',
|
path.join(opts.javaPath, 'bin/keytool'),
|
||||||
'-cacerts',
|
params.concat([
|
||||||
'-storepass',
|
'-storepass',
|
||||||
'changeit',
|
'changeit',
|
||||||
'-noprompt',
|
'-noprompt',
|
||||||
'-alias',
|
'-alias',
|
||||||
'mycert',
|
'mycert',
|
||||||
'-file',
|
'-file',
|
||||||
rooCaPath
|
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}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ async function run() {
|
||||||
securitySettings: core.getInput(
|
securitySettings: core.getInput(
|
||||||
constants.INPUT_MAVEN_SECURITY_SETTINGS_B64
|
constants.INPUT_MAVEN_SECURITY_SETTINGS_B64
|
||||||
),
|
),
|
||||||
javaPath: ''
|
javaPath: '',
|
||||||
|
javaVersion: version
|
||||||
};
|
};
|
||||||
|
|
||||||
const mvnVersion = core.getInput(constants.INPUT_MAVEN_VERSION);
|
const mvnVersion = core.getInput(constants.INPUT_MAVEN_VERSION);
|
||||||
|
|
Loading…
Add table
Reference in a new issue