Cannot resolve Maven artifacts through proxy

Description

In environments where the internet is accessed via a proxy, clj fails to resolve (download) Maven artifacts and instead exits with an opaque error message.

Proxies should be supported out of the box as they are common in corporate environments.

Support for configuring a proxy server could be added in deps.edn, or automatically by inspecting http_proxy, https_proxy etc. environment variables.

Maven settings.xml can also include proxy information, and this is ignored.

Environment

Clojure 1.9.0-RC2

Activity

Show:
import
November 14, 2018, 4:58 PM

Comment made by: avi

Is there a known workaround/hack that can enable using an HTTP proxy with the current version of tool.deps without having to patch it?

import
November 25, 2018, 12:44 AM

Comment made by: nwright

Hello, this problem is also affecting me. Quite annoying. Most systems I have used respect the well-known environment variables.

David Bürgin
December 15, 2018, 4:03 PM

I have updated the Maven settings patch with ’s bit that enables proxy authentication (I’ve listed you in a Co-authored-by: trailer in the commit).

David Bürgin
December 15, 2018, 4:21 PM

Reviewers: Here are some instructions on how to test patch

. It’s easy to do, you don’t need an actual proxy environment.

mitmproxy

Use the mitmproxy tool to run a local proxy server. Go to https://mitmproxy.org and download the binary package. On Linux this is just a tarball containing executable binaries.

You can directly start a proxy server in the extracted archive:

Trust the mitmproxy certificate

Because mitmproxy is, well, a MITM on TLS connections to Maven repos, you must temporarily add its CA certificate to the Java trust store. On Ubuntu 18.04, for example, you can use keytool to import the mitmproxy CA certificate (generated by mitmproxy on first run). Only root may write to the system trust store, so use sudo:

After testing, remove the certificate again with the following command:

Maven proxy settings

With the proxy set up and running, add a proxies configuration section in the Maven settings.xml file at ~/.m2/settings.xml. (If the file doesn’t exist, create it.)

Uncomment the username/password settings when using the authenticating proxy.

With all of this set up, tools.deps/Clojure tools should resolve artifacts through mitmproxy; you will see the requests flowing through in the mitmproxy UI.

Alex Miller
March 16, 2019, 5:24 PM

Committed and released in tools.deps.alpha 0.6.496

Assignee

Alex Miller

Reporter

David Bürgin

Labels

None

Approval

None

Patch

None

Priority

Major
Configure