Skip to content

Reading cafile from ssl.create_default_context causes ~143,000 disk operations in Windows #137560

@sloweclair

Description

@sloweclair

Bug report

Bug description:

When running the code below it causes ~143,000 disk operations to read in the entire file. This is because it is doing 2 bytes at a time for some reason.

import ssl
import certifi

ssl.create_default_context(cafile=certifi.where())

How to replicate

  1. Download & Run Procmon https://learn.microsoft.com/en-us/sysinternals/downloads/procmon
  2. Make sure you aren't running any other Python code to make the capture easier
  3. In the filter window have it filter for Process Name contains python
Image
  1. Make sure Procmon is capturing
  2. Run the python program above
  3. Observe all the disk operations Image

If reading the file normally with open then it behaves as expected and only does a handful of calls

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions