Hello, My web API needs client certificate while requesting from my IOS app (Ex. cert prompt on safari browser). The certificate was pushed by MDM app(A) on my device and it is available under (Settings/General/Device Management/Digital Workspace/certificate) and the same certificate i want to use to make WebAPI request in My App (B) on the same device.
Does it possible? If Yes, How can i achieve using Alamofire?
If the certificate was pushed to the device and accepted by the user, it should be part of the default evaluation chain automatically, so Alamofire shouldn't need to do anything. Is that not the case? Note that iOS 10.3 changed the way certificates are accepted by users, so you'll need to make sure it's active.
Hi, I am having similar issue, when I access the API endpoint from iOS safari, it prompts the user for selecting client certificate. But when i call the API endpoint with Alamofire, it simply times out.
We do not have direct support for client certificates in Alamofire at this time. You have a couple options. The first is to set the taskDidReceiveChallenge override closure while the other would be to subclass the SessionDelegate and override the task challenge API.
Once you've done that, you'll need to check for if the challenge's protection space auth method is NSURLAuthenticationMethodClientCertificate. If it is, then you'll need to build a URLCredential from your certificate and pass that off to the completion handler. This thread walks you through the basics.
Best of luck! 馃嵒
Hello @cnoon has direct support been added since 2017?
Is overriding taskDidReceiveChallenge still the goto method here?
Hi @avanarden, using taskDidReceiveChallenge is still the recommended approach.
Most helpful comment
We do not have direct support for client certificates in Alamofire at this time. You have a couple options. The first is to set the
taskDidReceiveChallengeoverride closure while the other would be to subclass theSessionDelegateand override the task challenge API.Once you've done that, you'll need to check for if the challenge's protection space auth method is
NSURLAuthenticationMethodClientCertificate. If it is, then you'll need to build aURLCredentialfrom your certificate and pass that off to the completion handler. This thread walks you through the basics.Best of luck! 馃嵒