Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Proxy authentication in iOS 4.3

I am doing some ios programming that accesses the AppStore via StoreKit and my own server over https. I am trying to access both these from behind a corporate firewall. I have access to proxy servers that require 'No Auth', 'Basic Auth', & 'NTLM Auth'.

Access through 'No Auth' has no problems, but the other two are giving me a headache. I am using 'NSURLRequest's to connect to my server but am getting back: [NSHTTPURLResponse statusCode]: 407 - proxy authentication required "Cache-Control" = "no-cache"; "Content-Length" = 2428; "Content-Type" = "text/html"; Expires = 0; "Proxy-Authenticate" = "Basic realm=\"WebMarshal Proxy Server\""; "Proxy-Connection" = "keep-alive"; Server = "WebMarshal Proxy"; Via = "1.1 NZ8KS49CH"; "X-Webmarshal-Requestid" = "8854B349-B35E-48EF-A643-3C6C6FEC5F9C"; }

Reading the URL Programming Guide suggests that NSURL class '...transparently supports both proxy servers and SOCKS gateways using the user’s system preferences.'

But it doesn't seem to be handling the job autonomously, yet I can find little reference about dealing with proxy authentication manually.

Must I manually rerun the request with a 'Proxy-Authorization' header ? If so then is then what interface is used for recalling or prompting the for current user credentials ?

BTW I am holding out no great hopes for getting NTLM authentication going as it looks like it may not be supported by NSURLConnection, but Basic Auth should be.

Thanks for any suggestions...

like image 261
Chris Avatar asked Nov 14 '22 22:11

Chris


1 Answers

YES you have to manually handle the proxy authentication request.

Read the section called authentication challanges see here.

In a nutshell, you respond to an event in your nsurlconnection delegate. You then ask the user for a proxy username and password, after which you then respond to the request with the authentication details. (You don't have to resend the request as such as iOS handles that).

like image 174
Rob Avatar answered Dec 15 '22 15:12

Rob