Using dnspython to override the socket resolver

I’ve recently been working on a simple domain monitoring tool that includes a module for retrieving TLS certificate data. Part of the tools functionality is that the user can specify the DNS server(s) handling resolution of the domains to be monitored. Using the dnspython library, the tool can set the desired resolvers, make queries, and avoid falling through to the system resolver. However, the module for querying TLS certificates makes use of the ssl std lib which uses the socket library. socket lib relies on the getaddrinfo or gethostbyname methods which are dependent on the system hosts file and resolver configuration. There is no native method in socket to override the resolver which would invalidate the intended function of my tool. ...

2026-04-19 · 2 min · 361 words · Aidan