'Change SSL Pinning mode on runtime in AFNetworking

We have a trouble with AFNetworking library when we check for SLL Pinning. We need to change SLL Pinning mode on runtime but changing doest not effect for some reason. For instance, we don't want to check sll pinning for first the request, but want for the other ones. Any help would be really appreciated.

Here is how we set the SSL mode dynamically with willCheckForSSLPinning variable;

if ([ConnectionUtil connectedToInternet]) {
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    if (willCheckForSSLPinning) {
        manager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
    } else {
        manager.securityPolicy = [AFSecurityPolicy defaultPolicy];   
    }
    ....
}


Solution 1:[1]

use [manager setSecurityPolicy: <yourSecurityPolicy>];

instead of manager.securityPolicy = <yourSecurityPolicy>;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ahmed Allam