Ios 使用writeToUrl更新生成中包含的文件(在application container.app中)

Ios 使用writeToUrl更新生成中包含的文件(在application container.app中),ios,objective-c,ssl,ssl-certificate,Ios,Objective C,Ssl,Ssl Certificate,我试图使用writeToUrl动态更新SSL证书,但出现以下错误: // Returns the first certificate in the cert chain SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0); // Returns a DER representation of a certificate given a certificate object. NSData *

我试图使用writeToUrl动态更新SSL证书,但出现以下错误:

// Returns the first certificate in the cert chain
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, 0);

// Returns a DER representation of a certificate given a certificate object.
NSData * remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate));

NSError *error;
BOOL didUpdateCertif = [remoteCertificateData writeToURL:localCertificateUrl options:NSDataWritingAtomic error:&error];
localCertificateUrl
的值类似于
file:///var/containers/Bundle/Application/79A3FE24-FA18-4DB9-9DDD-ED2135B47C5A/App-Name.app/certificate.cer

但是我得到了这个错误

Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “certif.cer” in the folder “App-Name”." UserInfo={NSFilePath=/var/containers/Bundle/Application/79A3FE24-FA18-4DB9-9DDD-ED2135B47C5A/App-Name.app/certif.cer, NSUnderlyingError=0x170249ae0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

是我做得不对还是无法动态更新构建中包含的文件

我刚刚发现
您无法写入此目录。为防止篡改,在安装时对捆绑包目录进行签名。写入此目录会更改签名并阻止应用程序启动。


。。或者不可能动态更新构建中包含的文件。是的,这是不可能的。是的,我刚刚发现
您不能写入此目录。为防止篡改,在安装时对捆绑包目录进行签名。写入此目录会更改签名并阻止应用程序启动。