Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Lion ignoring proxy set by configuration framework?

Hi,

I'm setting system proxy in my application with configuration framework. It worked in Leopard but it doesn't in Lion anymore. Proxy is successfully set (I can see it in network settings) but system ignores it. I have to go to network settings, change anything and press apply. Then it works. Anyone have same problems? Thanks. Code cut:



OSStatus authErr = noErr;

AuthorizationRef auth;


AuthorizationFlags rootFlags = kAuthorizationFlagDefaults

| kAuthorizationFlagExtendRights

| kAuthorizationFlagInteractionAllowed

| kAuthorizationFlagPreAuthorize;


authErr = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, rootFlags, &auth);


SCPreferencesRef prefsRef = SCPreferencesCreateWithAuthorization(NULL, CFSTR("idc"), NULL, auth);


BOOL success;


success = SCPreferencesLock(prefsRef, NO);


// Get available network services

SCNetworkSetRef networkSetRef = SCNetworkSetCopyCurrent(prefsRef);


CFArrayRef networkServicesArrayRef = SCNetworkSetCopyServices(networkSetRef);


//wifi for me, only testing

SCNetworkServiceRef networkServiceRef = CFArrayGetValueAtIndex((CFArrayRef)networkServicesArrayRef, 3);


NSString * name = (NSString*)SCNetworkServiceGetName(networkServiceRef);


// Get proxy protocol

SCNetworkProtocolRef proxyProtocolRef = SCNetworkServiceCopyProtocol(networkServiceRef, kSCNetworkProtocolTypeProxies);


NSDictionary *oldPreferences = (NSDictionary*)SCNetworkProtocolGetConfiguration(proxyProtocolRef);


NSString *wantedHost = @"localhost";


[oldPreferences setValue: wantedHost forKey:(NSString*)kSCPropNetProxiesHTTPProxy];

[oldPreferences setValue:[NSNumber numberWithBool:true] forKey:(NSString*)kSCPropNetProxiesHTTPEnable];

[oldPreferences setValue:[NSNumber numberWithInt:8080] forKey:(NSString*)kSCPropNetProxiesHTTPPort];


success = SCNetworkProtocolSetConfiguration(proxyProtocolRef, (CFDictionaryRef)oldPreferences);


success = SCPreferencesCommitChanges(prefsRef);


success = SCPreferencesApplyChanges(prefsRef);


SCPreferencesUnlock(prefsRef);


OSStatus err = SCError();

Mac OS X (10.7)

Posted on Jul 31, 2011 6:20 AM

Reply
2 replies

Lion ignoring proxy set by configuration framework?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.