Search code examples
objective-ccookiesosx-lionsandbox

NSHTTPCookieStorage + Sandboxing


I am having problems with combining [NSHTTPCookieStorage sharedHTTPCookieStorage] with Sandboxing. It appears like the class has no access to the Cookies.binarycookies file that is located in ~/Library/Cookies, even though I have allowed this location in my entitlements file in the com.apple.security.temporary-exception.files.home-relative-path.read-write array of permitted paths.

Apart from that, this is an Apple made class and should be working even without this modification.

I have also tried - (id)initWithStorageLocation:(NSURL*)storageFileURL, however this has been introduced in Mac OS X 10.6 and silently removed in Mac OS X 10.7, so I cannot use this either.

What can I do? All methods such as - (NSArray *)cookies return nothing.

I am building using the 10.7 SDK and the newest version of Xcode.

Edit: I've talked to someone who works for Apple and he's saying that the Cookie access system when sandboxed is identical to the iOS one. This means that you can never access the global Cookie database without your own implementation (which I will create now). NSHTTPCookieStorage will only reveal your own Cookies when sandboxed.


Solution

  • Have a look in the logs from Console app – if it's a sandboxing issue, it should leave a little more detail about the reason it's failing. You can use that to find other temporary exceptions you might need to allow it to work.

    Just because it's an Apple made class, it doesn't mean it will work. I had an issue with one of my apps using Apple's CoreMIDI API – had to add a couple of obscure com.apple.security.temporary-exception.mach-lookup.global-name entitlements to make it work.