{"id":5397,"date":"2014-03-30T21:26:58","date_gmt":"2014-03-30T21:26:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/alternative-method-for-nsurlrequests-private-setallowsanyhttpscertificateforhost-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:26:58","modified_gmt":"2014-03-30T21:26:58","slug":"alternative-method-for-nsurlrequests-private-setallowsanyhttpscertificateforhost-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/alternative-method-for-nsurlrequests-private-setallowsanyhttpscertificateforhost-collection-of-common-programming-errors\/","title":{"rendered":"Alternative method for NSURLRequest&#39;s private &ldquo;setAllowsAnyHTTPSCertificate:forHost:&rdquo;?-Collection of common programming errors"},"content":{"rendered":"<p>Actually, I&#8217;m testing with 10.6.8 and this code still works &#8212; it&#8217;s using the private API but checking that the selector exists (myurl is the NSURL I&#8217;m trying to load into a WebView or an NSURLConnection):<\/p>\n<pre><code>SEL selx = NSSelectorFromString(@\"setAllowsAnyHTTPSCertificate:forHost:\");\nif ( [NSURLRequest respondsToSelector: selx] )\n{\n    IMP fp;\n\n    fp = [NSURLRequest methodForSelector:selx];\n\n    (fp)([NSURLRequest class], selx, YES, [myurl host]);\n}\n<\/code><\/pre>\n<p>Note that &#8220;@selector&#8221; wasn&#8217;t used so that absolutely <em>all<\/em> the work would be done at runtime. That makes it about as safe and as hidden from Apple&#8217;s checks as can be, especially if you obscure the string.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Actually, I&#8217;m testing with 10.6.8 and this code still works &#8212; it&#8217;s using the private API but checking that the selector exists (myurl is the NSURL I&#8217;m trying to load into a WebView or an NSURLConnection): SEL selx = NSSelectorFromString(@&#8221;setAllowsAnyHTTPSCertificate:forHost:&#8221;); if ( [NSURLRequest respondsToSelector: selx] ) { IMP fp; fp = [NSURLRequest methodForSelector:selx]; (fp)([NSURLRequest class], [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5397","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5397"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5397\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}