r/Python • • 6d ago

Discussion PyInstaller on Windows: does code signing stop Smart App Control blocking the DLLs?

I ship a desktop app with a python backend frozen with pyinstaller, currently unsigned. Two problems on Windows:

  • SmartScreen "Windows protected your PC" on every fresh download
  • worse: on some users' machines Smart App Control blocks the bundled .pyd/.dll files ("An Application Control policy has blocked this file") and the app just dies on startup

I'm about to pay for signing, and the part I can't find a straight answer on is the pyinstaller side:

  1. Is signing the main exe enough, or do you have to sign every .pyd and .dll inside the bundle (incl. python3xx.dll and third party wheels) before freezing?
  2. Has anyone seen Smart App Control actually stop blocking after signing, or does it still flag new files until reputation builds?
  3. onefile vs onedir, does it matter here? onefile extracts to temp, which feels like exactly what SAC hates.

If you've been through this, what did your build pipeline end up looking like?

41 Upvotes

34 comments sorted by

View all comments

4

u/codariadev 6d ago

On 1: sign everything that gets loaded, not just the exe. SAC evaluates each binary as it loads, so an unsigned python3xx.dll or a .pyd from some wheel can still get blocked even if the launcher is signed. With onedir that's easy: build, run signtool over every .exe/.dll/.pyd in dist/yourapp, then sign the main exe last (and the installer, if you have one).

On 3: onedir is the easier path here. With onefile the bootloader unpacks to %TEMP% on every launch, and you'd have to sign the DLLs before they get packed into the archive, which PyInstaller doesn't do for you. Shipping onedir inside a signed installer (Inno Setup, MSIX) also gives you a stable install path instead of random temp folders.

On 2: SmartScreen and SAC are different things. SAC should stop hard-blocking once the files carry a valid signature from a trusted CA (that's the doc someone linked). SmartScreen is reputation-based and EV certs no longer skip the warm-up, so expect the "protected your PC" prompt for a while either way. If price is the issue, look at Azure Trusted Signing, it's much cheaper than a traditional cert and works with signtool.

Also timestamp the signatures (/tr + /td sha256), otherwise they stop validating when the cert expires.

6

u/sausix 6d ago

Don't sign third party DLLs which are already signed. You are giving your trust away for no reason. The Python DLLs should be signed by the Python foundation already.

1

u/codariadev 3d ago

Good catch, I should have said unsigned binaries only. Anything that already carries a valid signature (like the PSF-signed Python DLLs or signed VC runtime DLLs) should be left alone — just check which ones in dist/ are actually unsigned and sign those.

1

u/Ishannaik 3d ago

signing the dlls before pyinstaller packs them is what makes onefile sound like such a pain, didnt realise it wont do that for u. did u get azure trusted signing approved as an individual or did it need a registered company

1

u/codariadev 3d ago

I haven't been able to get it approved myself since I'm outside the US/Canada. Microsoft renamed it to Azure Artifact Signing, and individual developer validation for Public Trust is only open to folks in the US and Canada (with an Individual Azure billing account matching your government ID).

Organizations have a wider list (US, Canada, EU, UK, Australia, Japan, etc.), so if you're an individual outside the US/Canada you still end up needing either a registered company in a supported region or a regular OV cert from a traditional CA.

1

u/Ishannaik 3d ago

artifact signing being us/canada only for individuals is a big catch, so outside those two its basically a company or a regular OV cert. did u end up going the OV route or are ur builds still unsigned for now?