IOS https请求信任服务器

参考文档中方法二实现

添加信任

定义接口:
NSURLRequest+DummyInterface.h


//
//  NSURLRequest+DummyInterface.h
//  notification
//
//  Created by topwqp on 16/6/10.
//  Copyright (c) 2016年 topwqp. All rights reserved.
//

#import 
@interface NSURLRequest (IgnoreSSL)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host;
@end

定义实现:



//
//  NSURLRequest+DummyInterface.m
//  notification
//
//  Created by topwqp on 16/6/10.
//  Copyright (c) 2016年 topwqp. All rights reserved.
//

#import "NSURLRequest+IgnoreSSL.h"
@implementation NSURLRequest (IgnoreSSL)

    + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host
    {
        // ignore certificate errors only for this domain
        if ([host hasSuffix:@"yourhostname"])
        {
            return YES;
        }
        else
        {
            return NO;
        }
    }
    
    @end

你可能感兴趣的:(IOS https请求信任服务器)