@@ -157,21 +157,37 @@ export function downloadCertificate(cscLink: string): Promise<string> {
157
157
. thenReturn ( certPath )
158
158
}
159
159
160
- export let findIdentityRawResult : Promise < string > | null = null
160
+ export let findIdentityRawResult : Promise < Array < string > > | null = null
161
161
162
162
export async function findIdentity ( namePrefix : CertType , qualifier ?: string ) : Promise < string | null > {
163
163
if ( findIdentityRawResult == null ) {
164
164
// https://github.com/electron-userland/electron-builder/issues/481
165
- findIdentityRawResult = exec ( "security" , [ "find-identity" , "-v" , "-p" , "codesigning" , "-p" , "appleID" ] )
165
+ // https://github.com/electron-userland/electron-builder/issues/535
166
+ findIdentityRawResult = BluebirdPromise . all ( [
167
+ exec ( "security" , [ "find-identity" , "-v" ] )
168
+ . then ( it => it . trim ( ) . split ( "\n" ) . filter ( it => {
169
+ for ( let prefix of appleCertificatePrefixes ) {
170
+ if ( it . includes ( prefix ) ) {
171
+ return true
172
+ }
173
+ }
174
+ return false
175
+ } ) ) ,
176
+ exec ( "security" , [ "find-identity" , "-v" , "-p" , "codesigning" ] )
177
+ . then ( it => it . trim ( ) . split ( ( "\n" ) ) ) ,
178
+ ] )
179
+ . then ( it => {
180
+ const array = it [ 0 ] . concat ( it [ 1 ] )
181
+ . filter ( it => ! it . includes ( "(Missing required extension)" ) && ! it . includes ( "valid identities found" ) && ! it . includes ( "iPhone " ) && ! it . includes ( "com.apple.idms.appleid.prd." ) )
182
+ // remove 1)
183
+ . map ( it => it . substring ( it . indexOf ( ")" ) + 1 ) . trim ( ) )
184
+ return Array . from ( new Set ( array ) )
185
+ } )
166
186
}
167
187
168
188
// https://github.com/electron-userland/electron-builder/issues/484
169
189
//noinspection SpellCheckingInspection
170
- const lines = ( await findIdentityRawResult )
171
- . trim ( )
172
- . split ( "\n" )
173
- . filter ( it => ! it . includes ( "(Missing required extension)" ) && ! it . includes ( "valid identities found" ) && ! it . includes ( "iPhone " ) && ! it . includes ( "com.apple.idms.appleid.prd." ) )
174
-
190
+ const lines = await findIdentityRawResult
175
191
for ( let line of lines ) {
176
192
if ( qualifier != null && ! line . includes ( qualifier ) ) {
177
193
continue
0 commit comments