1

I user AF to send https request like

    [self.manager POST:downloadURLStirng parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        if (success)
            success(responseObject,passParameters);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if(failure)
            failure(operation.responseObject,error,passParameters);
    }];

and i have already set securityPolicy to YES

    self.manager.requestSerializer = [AFJSONRequestSerializer serializer];
self.manager.securityPolicy.allowInvalidCertificates = OPENSSL;

but i still got code -1012 and error_message : In order to validate a domain name for self signed certificates, you MUST use pinning.

1

2 Answers 2

1

This is sets security policy to allow invalid certificates and stops domain name validation also.:

AFSecurityPolicy *securityPolicy = [AFSecurityPolicy 
policyWithPinningMode:AFSSLPinningModeNone];
securityPolicy.allowInvalidCertificates = YES;

[securityPolicy setValidatesDomainName:NO];
-4

I searched for this line

'NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning.");'

and below this line I changed

'return NO;'
to

'return YES;'

and it did the magic.

Thanks.

3
  • This is working for me too but it is questionable if this is a good approach. Will give this a try first: stackoverflow.com/questions/27808249/…
    – Rick
    Dec 17, 2015 at 7:18
  • 1
    Rather allocate with: [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
    – Rick
    Dec 22, 2015 at 9:38
  • Why did you do this? What problem did it solve, and what advantages did it introduce?
    – Ky -
    Apr 22, 2021 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.