Curl Auto Proxy configuration Pac file

kenergy
Contributor

Hello All,

I am working on a script to curl something but we are using a .pac file,is this possible? If so anyone know how to?

1 ACCEPTED SOLUTION

dwandro92
Contributor III

Just to clarify, you can permanently set your proxy URL for use with terminal commands, but it won't work with PAC files. Refer to How to set proxy environment variable in Unix/Linux if you aren't already aware of how to do this.

View solution in original post

6 REPLIES 6

philburk
New Contributor III

As far as I know, no, curl doesn't support using javascript. I'm assuming that this script will be run from various networks and you won't know which proxy to use, hence the reliance upon the .pac file? You are able to supply curl with a proxy manually via the -x option but if that proxy will not apply to all situations, then I guess you're outta luck.

More here:

http://curl.haxx.se/docs/faq.html#Does_curl_support_Javascript_or

bumbletech
Contributor III

I think you could use a script:

#!/bin/sh

networksetup -setautoproxyurl Ethernet http://link/to.pac

dwandro92
Contributor III

You would need to find the address of the proxy server that the PAC file points to when it is executed, then set your environment variables (http_proxy, https_proxy) to point to that server.

If you have Kerberos authentication enabled on your proxy, you should be able to just do a kinit to get a Kerberos ticket, then open Safari and go to Google to generate a kerberos ticket for the proxy. You can confirm that a ticket was issued by using klist. Once complete, you can test using curl http://www.google.com. If done correctly, you'll get a long string of HTML/JavaScript. If not, you'll probably get a "host not found" or "proxy authentication required" error.

If you don't have Kerberos enabled, you would need to include credentials in the proxy environment variable string.

kenergy
Contributor

Thanks everyone for the replies!

The pac file for the OS is already set, and surfing the web is no problem. If you want to use terminal and curl a file that's where there is an issue.

so if I did

"curl --silent http://server.com"

this won't resolve, but if I take that url and stick it in a browser it does work.

dwandro92
Contributor III

Just to clarify, you can permanently set your proxy URL for use with terminal commands, but it won't work with PAC files. Refer to How to set proxy environment variable in Unix/Linux if you aren't already aware of how to do this.

kenergy
Contributor

Thanks @dwandro92