0

I was able to use this answer to help me log in to my app using a client certificate.

Getting Client Certificate for Mutual Authentication with Alamofire

Everything works beautifully for log-in. Now, I need to make another request to upload a file. I used the same bit of code from the previous post to take the p12 file and create my serverTrustPolicy and add it to my session manager, but when I make the request, the server tells me that I'm not passing the certificate to them.

I do not understand why the code would work for one instance, and not another. The only difference between the two is:

Works:

manager = Alamofire.SessionManager(serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicy))

Does not work:

manager = Alamofire.SessionManager(configuration: configuration, serverTrustPolicyManager : ServerTrustPolicyManager(policies: serverTrustPolicy))

Both are using the didChallenge Delegate exactly the same.

I would appreciate any insight.

Community
  • 1
  • 1
cmyers78
  • 76
  • 8

1 Answers1

0

So apparently the issue is due to having a configuration and a ServerTrustPolicyManager. When I only have a STPM and place my headers inside the upload function, the call works just fine. Perhaps something about trying to do two background calls in the app is causing issues. Default and ephemeral calls work just fine.

cmyers78
  • 76
  • 8