V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
twoconk
V2EX  ›  iDev

[求助] iOS 自签名证书 HTTPS 请求

  •  
  •   twoconk · 2020-07-08 11:49:16 +08:00 · 2216 次点击
    这是一个创建于 1617 天前的主题,其中的信息可能已经有所发展或是发生改变。
    怀疑 iOS 现在是不是完全不支持自签名证书了,调了一天的 HTTPS 请求,自签名证书的 HTTPS 请求一直提示 SSL 错误
    2 条回复    2020-07-21 16:09:43 +08:00
    twoconk
        1
    twoconk  
    OP
       2020-07-09 15:58:19 +08:00
    使用 libcurl 和 openssl 的库,可以通自签名证书的 https 请求,但不知道是否会影响审核
    twoconk
        2
    twoconk  
    OP
       2020-07-21 16:09:43 +08:00
    //[manager setSecurityPolicy:[self customSecurityPolicy]];
    //校验挑战认证
    [manager setAuthenticationChallengeHandler:^(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition , NSURLCredential * _Nullable)){

    NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
    __block NSURLCredential *credential = nil;

    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
    credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
    if (credential) {
    disposition = NSURLSessionAuthChallengeUseCredential;
    } else {
    disposition = NSURLSessionAuthChallengePerformDefaultHandling;
    }
    } else {
    disposition = NSURLSessionAuthChallengePerformDefaultHandling;
    }

    if (completionHandler) {
    completionHandler(disposition, credential);
    }
    }];
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1120 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 166ms · UTC 23:36 · PVG 07:36 · LAX 15:36 · JFK 18:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.