简体   繁体   中英

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];   
    }
    ....
}

use [manager setSecurityPolicy: <yourSecurityPolicy>];

instead of manager.securityPolicy = <yourSecurityPolicy>;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM