I'm writing a NSData object to a file using this code:
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"cert" ofType:@"p12"];
NSData *data = [NSData dataFromBase64String:cert];
NSLog(@"Data length is %i", [data length]);
[data writeToFile:thePath atomically:YES]; //doesn't matter atomically YES or NO, same result
And it prints out
Data length is 3078
However when I read the retrieved file I'm missing 70 bytes!
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"cert" ofType:@"p12"];
NSData *PKCS12Data = [[NSData alloc] initWithContentsOfFile:thePath];
NSLog(@"PKCS12Data length is %i", [PKCS12Data length]);
Which prints out:
PKCS12Data length is 3008
So what is going on here? Is there another way to create the file with all of its data?