@@ -141,11 +141,62 @@ async function codesign(
141141 entitlement : string | undefined ,
142142 keychain : string | undefined ,
143143 file : string ,
144+ tool ?: string ,
144145) {
145146 if ( identity === undefined ) {
146147 // XXX: typescript can ensure this at compile time
147148 throw new Error ( "--identity is required to sign" ) ;
148149 }
150+ if ( tool === 'rcodesign' ) {
151+ console . error ( 'WARNING: Signing with the experimental rcodesign tool' ) ;
152+ const args = [ ] ;
153+ args . push ( 'sign' ) ; // action
154+
155+ args . push ( '-v' ) ;
156+ args . push ( '--pem-source' ) ; // action
157+ const pemFile = '/Users/pancake/iphone.pem' ;
158+ args . push ( pemFile ) ;
159+
160+ args . push ( '--code-resources-path' ) ;
161+ args . push ( '/tmp/csreq.bin' ) ;
162+ // rcodesign bug makes this flag to not sign the binary at all
163+ args . push ( '--extra-digest' ) ;
164+ args . push ( 'sha256' ) ;
165+ args . push ( '--extra-digest' ) ;
166+ args . push ( 'sha384' ) ;
167+ // args.push('--binary-identifier');
168+ // args.push('com.tacobellspain.app');
169+ /*
170+ args.push('--code-signature-flags');
171+ args.push('runtime');
172+ */
173+ // --p12-file developer-id.p12
174+ // --p12-password-file ~/.certificate-password
175+ // --code-signature-flags runtime
176+ // path/to/executable
177+ /*
178+ if (typeof entitlement === 'string' && entitlement !== '') {
179+ args.push('-e');
180+ args.push(entitlement);
181+ }
182+ args.push('--binary-identifier');
183+ args.push(identity);
184+ */
185+ if ( typeof keychain === 'string' ) {
186+ args . push ( '--keychain-fingerprint' ) ;
187+ args . push ( keychain ) ;
188+ }
189+ args . push ( file ) ; // input
190+ args . push ( file + '.signed' ) ; // output
191+ console . error ( 'rcodesign ' + args . join ( ' ' ) ) ;
192+ const a = await execProgram ( 'rcodesign' , args , undefined ) ;
193+ if ( a . code === 0 ) {
194+ await execProgram ( 'rm' , [ '-rf' , file ] , undefined ) ;
195+ await execProgram ( 'mv' , [ file + '.signed' , file ] , undefined ) ;
196+ }
197+ console . log ( a . stderr ) ;
198+ return execProgram ( 'cp' , [ file , '/tmp/newsigned' ] , undefined ) ;
199+ }
149200 /* use the --no-strict to avoid the "resource envelope is obsolete" error */
150201 const args = [ "--no-strict" ] ; // http://stackoverflow.com/a/26204757
151202 args . push ( "-fs" , identity ) ;
@@ -181,6 +232,12 @@ async function verifyCodesign(
181232 file : string ,
182233 keychain ?: string ,
183234) : Promise < ExecResult > {
235+ /*
236+ if (tool === 'rcodesign') {
237+ const args = ['verify', file];
238+ return execProgram(getTool('rcodesign'), args, null, cb);
239+ }
240+ */
184241 const args = [ "-v" , "--no-strict" ] ;
185242 if ( typeof keychain === "string" ) {
186243 args . push ( "--keychain=" + keychain ) ;
0 commit comments