pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed

I’m also encountering the same error: SSL handshake failed.

I’m using MongoDB version 8.0.9, and I’ve verified that it is accessible from Network Access settings. Most of the time, the application works fine, but occasionally I get this SSL handshake error.
My application is running on the python:3.10-slim Docker image, which I believe is based on Debian Linux.
Can anyone suggest how to resolve this intermittent error?