Skip to content

Instantly share code, notes, and snippets.

@dalexsoto
Created November 6, 2012 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalexsoto/4025715 to your computer and use it in GitHub Desktop.
Save dalexsoto/4025715 to your computer and use it in GitHub Desktop.
add a host to the undocumented static trustedHosts property on NSURLConnection to ignore SSL validation failures
//add a host to the undocumented static trustedHosts property on NSURLConnection to ignore SSL validation failures
public class NSUrlExtensions
{
public static void AddTrustedHost (string trustedHost)
{
IntPtr classPtr_NSURLConnection = Class.GetHandle("NSURLConnection");
IntPtr sel_trustedHosts = Selector.GetHandle("trustedHosts");
IntPtr p = Messaging.IntPtr_objc_msgSend(classPtr_NSURLConnection, sel_trustedHosts);
NSMutableArray array = new NSMutableArray(p);
array.Add (new NSString(trustedHost));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment