AutomatedTester.BrowserMob
AutomatedTester.BrowserMob copied to clipboard
Set TrustAllServers for SSL sites
Hi,
I needed to tell browsermob to trustAllServers in order access a local ssl site in the down evnironment with self-signed certs. After reading all the docs about it i could find, i tried to implement a SetTrustAllServers method in Client.cs to model what exists in browsermob. I couldn't get that working; using the same post request as below after the proxy is already started does not seem to have any affect. The SetTrustAllServers method seems to be the best approach since it models how browsermob does it. However for the short term, i was able to get around the issue by modifying the Client ctor to this:
public Client(string url, bool trustAllServers = false)
{
if (String.IsNullOrEmpty(url))
throw new ArgumentException("url not supplied", "url");
_url = url;
_baseUrlProxy = String.Format("{0}/proxy", _url);
var paramters = trustAllServers ? "?trustAllServers=true" : null;
using (var response = MakeRequest(_baseUrlProxy + paramters, "POST"))
{...
and then in Server.cs:
public Client CreateProxy(bool trustAllServers = false)
{
return new Client(Url, trustAllServers);
}
If having a TrustAllServers method like browsermob is desired I'll keep at it until I figure it out and submit a pull request--just let me know.