I'd like to encrypt data stored on disk via default URLCache.
What I did is calling this method in my data tasks' completion block:
NSData *encryptedData = [data encrypted];
NSCachedURLResponse *newCachedResp = [[NSCachedURLResponse alloc]
initWithResponse:httpResponse
data:encryptedData];
[weakUrlCache storeCachedResponse:newCachedResp forRequest:urlRequest];
The problem I encountered though is that URLRequest (which is a key for URLCache) has Authorization header field with a token that I want to be encrypted as well. However, although the response is encrypted, URLRequest (with is headers) is not.
It makes me possible to pull Cache.db from a bundle and obtain user's token.
Is there any way better way to encrypt that data?