18
18
__copyright__ = "Copyright (C) 2020-2024 Orsiris de Jong"
19
19
__description__ = "Windows authenticode signature tool"
20
20
__licence__ = "BSD 3 Clause"
21
- __version__ = "0.5 .0"
22
- __build__ = "2024090801 "
21
+ __version__ = "0.6 .0"
22
+ __build__ = "2025051201 "
23
23
24
24
import os
25
25
import sys
26
-
26
+ from logging import getLogger
27
27
from typing import Optional , Union
28
28
from command_runner import command_runner
29
29
from ofunctions .file_utils import get_paths_recursive
30
30
from ofunctions .network import check_http_internet
31
31
from windows_tools .bitness import is_64bit , is_64bit_executable
32
32
33
33
34
+ logger = getLogger ()
35
+
36
+
34
37
CURRENT_EXECUTABLE = os .path .abspath (sys .argv [0 ])
35
38
CURRENT_DIR = os .path .dirname (CURRENT_EXECUTABLE )
36
39
dont_sign_file = os .path .join (CURRENT_DIR , "signtool.err.log" )
@@ -141,7 +144,7 @@ def get_timestamp_server(self):
141
144
"http://timestamp.globalsign.com/scripts/timstamp.dll" ,
142
145
]
143
146
for server in ts_servers :
144
- if check_http_internet ([server ]):
147
+ if check_http_internet (fqdn_servers = [server ]):
145
148
self .authority_timestamp_url = server
146
149
return True
147
150
raise ValueError ("No online timeserver found" )
@@ -158,12 +161,10 @@ def sign(
158
161
elif bitness in [64 , "64" , "x64" ]:
159
162
signtool = os .environ .get ("SIGNTOOL_X64" , self .detect_signtool ("x64" ))
160
163
else :
161
- if not bitness :
162
- raise ValueError (
163
- "Cannot autodetect bitness. Please specify bitness or install win32file"
164
+ logger .info (
165
+ f"Cannot autodetect bitness of executable { executable } . Defaulting to 64 bit signtool"
164
166
)
165
- else :
166
- raise ValueError ("Bogus bitness." )
167
+
167
168
168
169
if not os .path .exists (signtool ):
169
170
raise EnvironmentError ("Could not find valid signtool.exe" )
@@ -184,7 +185,6 @@ def sign(
184
185
cmd += ' "{}"' .format (executable )
185
186
186
187
if dry_run :
187
- print ("DRY RUN: {}" .format (cmd ))
188
188
return True
189
189
else :
190
190
# Make sure we don't sign automatically in order to prevent an EV certificate token to be blocked because of bogus password attempts
0 commit comments