Fedora 26: dnf update not working behind proxy – failed to synchronize cache for repo ‘updates’

dnffedoraPROXY

On Fedora 26 when I do sudo dnf -v update I get the error

>     Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache,
> needs-restarting, playground, repoclosure, repograph, repomanage,
> reposync, system-upgrade
>     DNF version: 2.6.3
>     cachedir: /var/cache/dnf
>     Cannot download 'http://download.fedoraproject.org/pub/fedora/linux/updates/26/x86_64/':
> Cannot download repomd.xml: Cannot download repodata/repomd.xml: All
> mirrors were tried.
>     Error: Failed to synchronize cache for repo 'updates'

I configured both my system-wide proxy and the proxy in dnf.conf. Other connections such as the browser work with this proxy. The proxy requires authentication – I have set the needed values in dnf.conf proxy_username and proxy_password.

I also have a .bashrc which sets http_proxy=http://username:password@proxy:port/. Then if I run curl http://download.fedoraproject.org/pub/fedora/linux/updates/26/x86_64/repodata/repomd.xml, it fails with HTTP 407. It works if I add --proxy-ntlm. According to the bugzilla, dnf has been already patched so that it permits NTLM when calling into libcurl.

However, yum additionally used to disable Kerberos/"negotiate" authentication, because in some cases that would be the first option offered, and it would fail where NTLM would work. A patch was offered for this second, but the bug was closed after resolving only the first problem…

How can I get dnf update to work?

Best Answer

I finally found a solution. The problem is this bug, which is still not fixed: https://bugzilla.redhat.com/show_bug.cgi?id=1387622

I had to edit /usr/lib/python3.6/site-packages/dnf/repo.py and change the following:

-        h.setopt(librepo.LRO_PROXYAUTH, True)
+        h.setopt(librepo.LRO_PROXYAUTHMETHODS, 8)
Related Question