Here's the request/response when I build the request manually to validate username and password before sending the the URL to the calendar app.
Note that the string bWVyZWRpdGg6VGVzdDEyMzRA is the base64 encoded of meredith:Test1234@
HEAD /my-calendar-subscription-server/1632a50c-7b0c-4fb9-b46a-45c1de0ac291/calendar.ics HTTP/1.1
Host: my-host.com
Accept: */
Content-Length: 0
Connection: keep-alive
Proxy-Connection: keep-alive
User-Agent: my-app-ios/14 CFNetwork/758.1.6 Darwin/15.0.0
Accept-Language: en-us
Authorization: Basic bWVyZWRpdGg6VGVzdDEyMzRA
Accept-Encoding: gzip, deflate
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 189
Content-Type: text/calendar;charset=UTF-8
Date: Fri, 20 Nov 2015 10:44:08 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
X-Application-Context: application:default:4150
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Connection: keep-alive
Then I build the URL to pass it to the calendar app.
I use NSURLComponent and this is the URL I pass to NSApplication openURL
http://meredith:Test1234%40@my-host.com/my-calendar-subscription-server/1632a50c-7b0c-4fb9-b46a-45c1de0ac291/calendar.ics
I set the password as it is using NSURLComponent setPassword, without any encoding, and of course they are URL encoded in the final URL.
These are the requests sent by the Calendar app
First request
GET /my-calendar-subscription-server/1632a50c-7b0c-4fb9-b46a-45c1de0ac291/calendar.ics HTTP/1.1
Host: my-host.com
Proxy-Connection: keep-alive
Accept: text/calendar
User-Agent: iOS/9.1 (13B143) dataaccessd/1.0
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.1 401 Unauthorized
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Language: en
Content-Type: text/html;charset=utf-8
Date: Fri, 20 Nov 2015 10:44:08 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
WWW-Authenticate: Basic realm="MyRealm"
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Length: 1104
Connection: keep-alive
Second request
GET /my-calendar-subscription-server/1632a50c-7b0c-4fb9-b46a-45c1de0ac291/calendar.ics HTTP/1.1
Host: my-host.com
Connection: keep-alive
Proxy-Connection: keep-alive
Accept: text/calendar
User-Agent: iOS/9.1 (13B143) dataaccessd/1.0
Accept-Language: en-us
Authorization: Basic bWVyZWRpdGg6VGVzdDEyMzQlNDA=
Accept-Encoding: gzip, deflate
HTTP/1.1 401 Unauthorized
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Language: en
Content-Type: text/html;charset=utf-8
Date: Fri, 20 Nov 2015 10:44:08 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
WWW-Authenticate: Basic realm="MyRealm"
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Length: 1040
Connection: keep-alive
Note that the string bWVyZWRpdGg6VGVzdDEyMzQlNDA= is the base64 encoded of meredith:Test1234%40 so the server fails to validate username/password.
What I'm asking is: it there a way to tell the Calendar app not to use the URL encoded version of username and password when it builds the base64 auth string?
At the moment I'm solving this issue on the server side with a filter based on the user agent (if iOS then -> base64 decode -> URL decode -> base64 encode)
Thank you for your attention
Vale