I want to allow invalid SSL certificates. My main code is below:
myClient = [[MyClient alloc] init];
[myClient getHtml:@"/path/to/the/distination.html"];
The MyClient class code is below:
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
@interface MyClient : NSObject
- (void)getHtml:(NSString *)path;
@end
#define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_
@implementation MyClient
- (void)getHtml:(NSString *)path
{
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://trusted.server.net"]];
[httpClient getPath:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error = %@", error);
}];
}
@end
I read below page and tried the macro but this doesn't work.
Self Signed certificate SSL · Issue #189 · AFNetworking/AFNetworking https://github.com/AFNetworking/AFNetworking/issues/189
Please help me...
if you are using RestKit using
won't work, instead do this:
in your project, click on RestKit.xcodeproj go to project > Build Settings > Preprocessor Macros
and add
_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_=1
thats finished.
if you are using RestKit using
won't work, instead do this:
if you added rest kit manually to your project, click on RestKit.xcodeproj go to project > Build Settings > Preprocessor Macros
and add
_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_=1
thats finished.
You can now use the allowsInvalidSSLCertificate property of the AFHTTPClient. No need to use defines in the latest versions of AFNetworking.
I am using RestKit so
does not work. The option is not propagated to the operations created by restkit.
I am using cocoapods so any changes in the pch file or the pods project get overriden. The "hack" I have been using is a cocoapod post-install operation that adds the required preprocessor definition. At the end of my pod file I have added:
Note that if you are installing through CocoaPods,
#define
-ing this macro in your project will not be enough--the compiler macro must be set when compiling the static library in order for it to take effect.I encountered the same problem and no one of the solutions that I read works.
For me the only workaround is set the AFSecurityPolicy like this:
I decided to reply although the question is old, maybe can help someone.