I operate my own tileserver for maps. This server is accessible via HTTPS with an self signed certificate. Is there a chance to use MKTileOverlay
static NSString * const template = @"https://tile.myserverwithselfsignedcertificate.org/{z}/{x}/{y}.png";
MKTileOverlay *overlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
overlay.canReplaceMapContent = YES;
[self.mapView addOverlay:overlay
level:MKOverlayLevelAboveLabels];
wiht a self-signed-certificate. I receive in the XCode log window unfortunately just an error message that the certificate is invalid.
For direct NSURLConnection requests I can use the solution as decribed e.g. here: http://www.cocoanetics.com/2010/12/nsurlconnection-with-self-signed-certificates/
But this does not work for my customized MKTileOverlay class.
Has anyone an idea if this is possible?
EDIT 21st August 2015
I believe I have to override the MKTileOverlay to something like this:
- (void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *data, NSError *error))result
{
NSURLRequest *request = [NSURLRequest requestWithURL:[self URLForTilePath:path]
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:20];
connectionApi = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
}
- (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data
{
[myData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)conn
{
// myData includes now the required tile,
// but how to pass it back to the result
// block of the loadTileAtPath method???
}
Has anyone an idea how too solve this?
I was able to solve it so: