LetsEncrypt certificates need to be updated every 2-3 months, so won't this code fail when the certificate on the server changes? Aren't you better off trusting the root cert(s) which don't change very often?
This will work fine on the bench, but will break in a few months, probably at the customers' site.
I hope no one reads this website and follows that advice.