CFNetworkCopySystemProxySettings

Why is this function unable to obtain system proxy information on Mac OS 10.12.5?

Replies

This is working for me:

  1. I created a tiny test project to print the result.

    import Foundation
    
    
    print(CFNetworkCopySystemProxySettings())

    .

  2. I use the Network preferences panel to configure my network interface to use

    proxy.example.com:8080
    as the HTTP proxy.
  3. I ran my test program and it printed the results I was expecting:

    $ ./ProxyDump
    Optional(Swift.Unmanaged<__ObjC.CFDictionary>(_value: {
        ExceptionsList =     (
            "*.local",
            "169.254/16"
        );
        FTPPassive = 1;
        HTTPEnable = 1;
        HTTPPort = 8080;
        HTTPProxy = "proxy.example.com";
        "__SCOPED__" =     {
            en0 =         {
                ExceptionsList =             (
                    "*.local",
                    "169.254/16"
                );
                FTPPassive = 1;
                HTTPEnable = 1;
                HTTPPort = 8080;
                HTTPProxy = "proxy.example.com";
            };
        };
    }))

    .

This was on 10.12.6 but I don’t have any reason to suspect that 10.12.5 would be any different.

How exactly as you testing this?

IMPORTANT Be aware that the system uses the proxy settings for the primary interface. If, for example, you set proxy settings on Wi-Fi and then plug-in Ethernet, the Wi-Fi settings won’t apply because Ethernet is primary.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"