Skip to content

Commit b2eb4b3

Browse files
Allow the specified identity to be the SHA-1 version (#98)
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent 1e57db2 commit b2eb4b3

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

cli.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,18 @@ async function init() {
167167

168168
ora.text = 'Code signing DMG';
169169
let identity;
170-
const {stdout} = await execa('/usr/bin/security', ['find-identity', '-v', '-p', 'codesigning']);
171-
if (cli.flags.identity && stdout.includes(`"${cli.flags.identity}"`)) {
170+
if (cli.flags.identity) {
171+
// We skip identity validation to support both named and SHA-1 formats; let system validate.
172172
identity = cli.flags.identity;
173-
} else if (!cli.flags.identity && stdout.includes('Developer ID Application:')) {
174-
identity = 'Developer ID Application';
175-
} else if (!cli.flags.identity && stdout.includes('Mac Developer:')) {
176-
identity = 'Mac Developer';
177-
} else if (!cli.flags.identity && stdout.includes('Apple Development:')) {
178-
identity = 'Apple Development';
173+
} else {
174+
const {stdout} = await execa('/usr/bin/security', ['find-identity', '-v', '-p', 'codesigning']);
175+
if (!cli.flags.identity && stdout.includes('Developer ID Application:')) {
176+
identity = 'Developer ID Application';
177+
} else if (!cli.flags.identity && stdout.includes('Mac Developer:')) {
178+
identity = 'Mac Developer';
179+
} else if (!cli.flags.identity && stdout.includes('Apple Development:')) {
180+
identity = 'Apple Development';
181+
}
179182
}
180183

181184
if (!identity) {

test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test('main', async t => {
1414
await execa(path.join(__dirname, 'cli.js'), ['--identity=0', path.join(__dirname, 'fixtures/Fixture.app')], {cwd});
1515
} catch (error) {
1616
// Silence code signing failure
17-
if (!error.message.includes('No suitable code signing')) {
17+
if (!error.message.includes('The specified item could not be found in the keychain')) {
1818
throw error;
1919
}
2020
}
@@ -29,7 +29,7 @@ test('binary plist', async t => {
2929
await execa(path.join(__dirname, 'cli.js'), ['--identity=0', path.join(__dirname, 'fixtures/Fixture-with-binary-plist.app')], {cwd});
3030
} catch (error) {
3131
// Silence code signing failure
32-
if (!error.message.includes('No suitable code signing')) {
32+
if (!error.message.includes('The specified item could not be found in the keychain')) {
3333
throw error;
3434
}
3535
}
@@ -44,7 +44,7 @@ test('app without icon', async t => {
4444
await execa(path.join(__dirname, 'cli.js'), ['--identity=0', path.join(__dirname, 'fixtures/Fixture-no-icon.app')], {cwd});
4545
} catch (error) {
4646
// Silence code signing failure
47-
if (!error.message.includes('No suitable code signing')) {
47+
if (!error.message.includes('The specified item could not be found in the keychain')) {
4848
throw error;
4949
}
5050
}

0 commit comments

Comments
 (0)