|
| 1 | +diff --git a/Source/GSEasyHandle.m b/Source/GSEasyHandle.m |
| 2 | +index 576a41205..7eb15d512 100644 |
| 3 | +--- a/Source/GSEasyHandle.m |
| 4 | ++++ b/Source/GSEasyHandle.m |
| 5 | +@@ -173,6 +173,24 @@ @implementation GSEasyHandle |
| 6 | + struct curl_slist *_headerList; |
| 7 | + } |
| 8 | + |
| 9 | ++#ifdef __ANDROID__ |
| 10 | ++static NSData *CABundleData() { |
| 11 | ++ static NSData *result = nil; |
| 12 | ++ static dispatch_once_t predicate; |
| 13 | ++ |
| 14 | ++ dispatch_once(&predicate, ^{ |
| 15 | ++ NSString *caBundlePath = [[NSBundle mainBundle] pathForResource:@"cacert" ofType:@"pem"]; |
| 16 | ++ if (caBundlePath) { |
| 17 | ++ result = [[NSData alloc] initWithContentsOfFile:caBundlePath]; |
| 18 | ++ } else { |
| 19 | ++ NSLog(@"Warning: missing CA bundle path (cacert.pem) in app bundle"); |
| 20 | ++ } |
| 21 | ++ }); |
| 22 | ++ |
| 23 | ++ return result; |
| 24 | ++} |
| 25 | ++#endif |
| 26 | ++ |
| 27 | + - (instancetype) initWithDelegate: (id<GSEasyHandleDelegate>)delegate |
| 28 | + { |
| 29 | + if (nil != (self = [super init])) |
| 30 | +@@ -184,6 +202,18 @@ - (instancetype) initWithDelegate: (id<GSEasyHandleDelegate>)delegate |
| 31 | + _errorBuffer = memset(eb, 0, sizeof(char) * (CURL_ERROR_SIZE + 1)); |
| 32 | + |
| 33 | + [self setupCallbacks]; |
| 34 | ++ |
| 35 | ++#ifdef __ANDROID__ |
| 36 | ++ // set CA certificate store (must be stored in app bundle) |
| 37 | ++ NSData *caBundleData = CABundleData(); |
| 38 | ++ if (caBundleData) { |
| 39 | ++ struct curl_blob blob; |
| 40 | ++ blob.data = (void *)caBundleData.bytes; |
| 41 | ++ blob.len = caBundleData.length; |
| 42 | ++ blob.flags = CURL_BLOB_COPY; |
| 43 | ++ handleEasyCode(curl_easy_setopt(_rawHandle, CURLOPT_CAINFO_BLOB, &blob)); |
| 44 | ++ } |
| 45 | ++#endif |
| 46 | + } |
| 47 | + |
| 48 | + return self; |
0 commit comments