@@ -51,43 +51,53 @@ export async function sign(workDir: string) {
51
51
defaults ( config . win , DEFAULT_WINDOWS_CONFIG ) ;
52
52
53
53
// Sign individual files. See https://github.com/electron-userland/electron-builder/issues/5968
54
+ // We built this docker.exe, so we need to sign it
55
+
54
56
const unpackedDir = path . join ( workDir , 'unpacked' ) ;
55
- const internalDir = 'resources/resources/win32/internal' ;
57
+ const resourcesRootDir = 'resources/resources/win32' ;
58
+ const internalDir = path . join ( resourcesRootDir , 'internal' ) ;
59
+ const binDir = path . join ( resourcesRootDir , 'bin' ) ;
60
+ const whiteList : Record < string , Array < string > > = {
61
+ '.' : [ 'Rancher Desktop.exe' ] ,
62
+ [ resourcesRootDir ] : [ 'wsl-helper.exe' ] ,
63
+ [ internalDir ] : [ 'host-resolver.exe' , 'privileged-service.exe' , 'steve.exe' , 'vtunnel.exe' ] ,
64
+ [ binDir ] : [ 'docker.exe' , 'docker-credential-none.exe' , 'nerdctl.exe' , 'rdctl.exe' ] ,
65
+ } ;
66
+
67
+ const toolPath = path . join ( await getSignVendorPath ( ) , 'windows-10' , process . arch , 'signtool.exe' ) ;
68
+ const toolArgs = [
69
+ 'sign' ,
70
+ '/debug' ,
71
+ '/sha1' , certFingerprint ,
72
+ '/fd' , 'SHA256' ,
73
+ '/td' , 'SHA256' ,
74
+ '/tr' , config . win . rfc3161TimeStampServer as string ,
75
+ '/du' , 'https://rancherdesktop.io' ,
76
+ ] ;
77
+
78
+ if ( certPassword . length > 0 ) {
79
+ toolArgs . push ( '/p' , certPassword ) ;
80
+ }
81
+
82
+ for ( const subDir in whiteList ) {
83
+ for ( const fileName of whiteList [ subDir ] ) {
84
+ const fullPath = path . join ( unpackedDir , subDir , fileName ) ;
85
+
86
+ // Fail if a whitelisted file doesn't exist
87
+ await fs . promises . access ( fullPath ) ;
88
+ console . log ( `Signing ${ fullPath } ` ) ;
89
+
90
+ await childProcess . spawnFile ( toolPath , [ ...toolArgs , fullPath ] , { stdio : 'inherit' } ) ;
91
+ }
92
+ }
56
93
57
- // make privileged-service.exe available to the instller during signing
94
+ // make privileged-service.exe available to the installer during signing
58
95
const privilegedServiceFile = 'privileged-service.exe' ;
59
96
const privilegedServiceFrom = path . join ( unpackedDir , internalDir , privilegedServiceFile ) ;
60
97
const privilegedServiceTo = path . join ( process . cwd ( ) , 'resources/win32/internal' , privilegedServiceFile ) ;
61
98
62
99
await fs . promises . copyFile ( privilegedServiceFrom , privilegedServiceTo ) ;
63
100
64
- for ( const subDir of [ '.' , internalDir ] ) {
65
- for ( const fileName of await fs . promises . readdir ( path . join ( unpackedDir , subDir ) ) ) {
66
- if ( ! fileName . endsWith ( '.exe' ) ) {
67
- continue ;
68
- }
69
- console . log ( `Signing ${ fileName } ` ) ;
70
-
71
- const toolPath = path . join ( await getSignVendorPath ( ) , 'windows-10' , process . arch , 'signtool.exe' ) ;
72
- const toolArgs = [
73
- 'sign' ,
74
- '/debug' ,
75
- '/sha1' , certFingerprint ,
76
- '/fd' , 'SHA256' ,
77
- '/td' , 'SHA256' ,
78
- '/tr' , config . win . rfc3161TimeStampServer as string ,
79
- '/du' , 'https://rancherdesktop.io' ,
80
- ] ;
81
-
82
- if ( certPassword . length > 0 ) {
83
- toolArgs . push ( '/p' , certPassword ) ;
84
- }
85
- toolArgs . push ( path . join ( unpackedDir , subDir , fileName ) ) ;
86
-
87
- await childProcess . spawnFile ( toolPath , toolArgs , { stdio : 'inherit' } ) ;
88
- }
89
- }
90
-
91
101
// Generate an electron-builder.yml forcing the use of the cert.
92
102
const newConfigPath = path . join ( workDir , 'electron-builder.yml' ) ;
93
103
0 commit comments