I am developing an app and I would like to enable my iOS Simulator and dev device to connect to the CosmosDB Emulator running on my windows laptop.
I can set the proper endpoint url, pointing to the emulator, but the Trust for the SSL fails as I am accessing it via IP, and the Azure CosmosDB Certificate has a fixed set of Subject Alternative Names:
- DNS Name = localhost
- DNS Name = <my windows hostname>
- IP Address = 127.0.0.1
- IP Address = 172.18.222.81
- DNS Name = 127.0.0.1
- DNS Name = 172.18.222.81
Now, for the simulator I suppose I can solve it with my hosts file and just map to my Windows IP. Or use Charles Proxy and it's DNS Spoofing, but this fails to work on my development device. The hosts file I cannot change, and Charles Proxy will proxy web requests from Safari using the DNS spoofing from the app, but the DocumentClient
from Microsoft.Azure.Documents.Client
appears not to use the proxy at all.
I get a name resolution error when I try from the device when using https://<my windows hostname>:8081
as the endpoint url.
System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: NameResolutionFailure
I can however setup my own HttpClient and enable the Proxy from a provided HttpClientHandler
and I can indeed, without a name resolution error, pull down the html from the emulator at: https://<my windows hostname>:8081/_explorer/index.html
Both of these will successfully use the proxy and fetch the html:
var settings = CoreFoundation.CFNetwork.GetSystemProxySettings();
var address = $"{settings.HTTPProxy}:{settings.HTTPPort}";
HttpClientHandler proxyHandler = new HttpClientHandler()
{
Proxy = new WebProxy(Address: address, BypassOnLocal: false)
UseProxy = true,
}
httpClient = new HttpClient(proxyHandler);
And this one
HttpClientHandler proxyHandler = new HttpClientHandler()
{
Proxy = CoreFoundation.CFNetwork.GetDefaultProxy(),
UseProxy = true,
}
httpClient = new HttpClient(proxyHandler);
So I know it can work, it just seems like DocumentClient
from Microsoft.Azure.Documents.Client
won't use any proxy and I could not find a way to configure it to use one unless I missed something.