0

I have two iOS dev accounts. I use my dev account to make tests. After finishing the development I decided to change the project certificate and set it to client's Apple Dev account.

When I use the first one (my Apple account), the requests are made through Alamofire return what expected. But when I set the second certificate I always get errors such as 401 Unauthorized Error. I think it sends irrelevant data to the server.

When I use the built in NSURLSession framework, it works fine on both Apple Dev accounts. So it is related with certificates and Alamofire but couldn't find the problem for days.

I've tried ServerTrustPolicy for Alamofire instance but didn't help. Also I've set App Transport Security Settings in the info.plist file, that didn't help as well.

Is there anyone who has experienced this problem? Thanks.

aytek
  • 1,842
  • 24
  • 32
  • I did not understand: what are you requesting exactly with Alamofire ? – Julien Quere Aug 28 '16 at 14:36
  • Some json data from the server, its content doesn't matter. I have two services, one is for getting user detail, the other for getting user orders. Both don't work. – aytek Aug 28 '16 at 14:57
  • And that's your server that reply your a `401 Unauthorized Error` when you change your app signing certificate ? If yes: how do you authenticate with this server ? – Julien Quere Aug 28 '16 at 15:08
  • @JulienQuere thanks for your answer. Basically everything works fine with my first Apple Dev Account. There is nothing wrong with the services, server and so forth. The problem is that when I switch to the other Apple Dev account, Alamofire doesn't work. Makes sense? – aytek Aug 28 '16 at 15:26
  • That's very strange. If Alamofire is able to give you a 401, it means that it works enough to "talk" to the server. Have you tried with other services ? (like https://httpbin.org ). Once again: 401 is an HTTP response from the server, so we have to wonder "why server is responding a 401 ?". How do you authenticate to the server ? – Julien Quere Aug 28 '16 at 15:46
  • @JulienQuere please don't focus on the server side. My problem is related with Apple dev account and Alamofire. It should be something related with developer certificate. Not sure how Alamofire works but it works upon your Apple Dev certificate, I'm sure about that. Lastly, my server doesn't respond 401 with my certificate, only with the second certificate it gives that error, because iOS app sends irrelevant data to the server in case I set my client's certificate to the iOS app. – aytek Aug 28 '16 at 16:52
  • Sorry to repeat again, but: "How do you authenticate to the server ?". If the server respond a 401, it mean that it do no recognise your identification parameters. Is it just username / password ? Do it depends of you Bundle Identifier ? Also: did you check that nothing else than dev account is changed ? – Julien Quere Aug 28 '16 at 17:05
  • @JulienQuere thanks for your comments. It seems it's a Xcode cache problem. – aytek Aug 28 '16 at 22:10

1 Answers1

0

After trying many things, finally I've decided to clear the XCode cache and now it works without any problem. And lesson learned; you should clear cache if you switch between Teams (Apple Dev Accounts) in XCode.

Community
  • 1
  • 1
aytek
  • 1,842
  • 24
  • 32