Backport r30520 to fix deadlock in HTTPS setup.