Skip to content

Commit b585318

Browse files
committed
signtool: Allow bitness fallback
1 parent e3ea395 commit b585318

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

windows_tools/signtool/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818
__copyright__ = "Copyright (C) 2020-2024 Orsiris de Jong"
1919
__description__ = "Windows authenticode signature tool"
2020
__licence__ = "BSD 3 Clause"
21-
__version__ = "0.5.0"
22-
__build__ = "2024090801"
21+
__version__ = "0.6.0"
22+
__build__ = "2025051201"
2323

2424
import os
2525
import sys
26-
26+
from logging import getLogger
2727
from typing import Optional, Union
2828
from command_runner import command_runner
2929
from ofunctions.file_utils import get_paths_recursive
3030
from ofunctions.network import check_http_internet
3131
from windows_tools.bitness import is_64bit, is_64bit_executable
3232

3333

34+
logger = getLogger()
35+
36+
3437
CURRENT_EXECUTABLE = os.path.abspath(sys.argv[0])
3538
CURRENT_DIR = os.path.dirname(CURRENT_EXECUTABLE)
3639
dont_sign_file = os.path.join(CURRENT_DIR, "signtool.err.log")
@@ -141,7 +144,7 @@ def get_timestamp_server(self):
141144
"http://timestamp.globalsign.com/scripts/timstamp.dll",
142145
]
143146
for server in ts_servers:
144-
if check_http_internet([server]):
147+
if check_http_internet(fqdn_servers=[server]):
145148
self.authority_timestamp_url = server
146149
return True
147150
raise ValueError("No online timeserver found")
@@ -158,12 +161,10 @@ def sign(
158161
elif bitness in [64, "64", "x64"]:
159162
signtool = os.environ.get("SIGNTOOL_X64", self.detect_signtool("x64"))
160163
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"
164166
)
165-
else:
166-
raise ValueError("Bogus bitness.")
167+
167168

168169
if not os.path.exists(signtool):
169170
raise EnvironmentError("Could not find valid signtool.exe")
@@ -184,7 +185,6 @@ def sign(
184185
cmd += ' "{}"'.format(executable)
185186

186187
if dry_run:
187-
print("DRY RUN: {}".format(cmd))
188188
return True
189189
else:
190190
# Make sure we don't sign automatically in order to prevent an EV certificate token to be blocked because of bogus password attempts
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ofunctions.file_utils>=1.0.2
22
ofunctions.network>=1.3.2
33
command_runner>=1.2.1
4-
windows_tools.bitness>=0.2.0
4+
windows_tools.bitness>=0.2.1
55
ofunctions.file_utils
6-
ofunctions.network>=1.6.0
6+
ofunctions.network>=1.6.1

0 commit comments

Comments
 (0)