久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='pJLcj'></tfoot>
      <bdo id='pJLcj'></bdo><ul id='pJLcj'></ul>

      <i id='pJLcj'><tr id='pJLcj'><dt id='pJLcj'><q id='pJLcj'><span id='pJLcj'><b id='pJLcj'><form id='pJLcj'><ins id='pJLcj'></ins><ul id='pJLcj'></ul><sub id='pJLcj'></sub></form><legend id='pJLcj'></legend><bdo id='pJLcj'><pre id='pJLcj'><center id='pJLcj'></center></pre></bdo></b><th id='pJLcj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pJLcj'><tfoot id='pJLcj'></tfoot><dl id='pJLcj'><fieldset id='pJLcj'></fieldset></dl></div>
    1. <legend id='pJLcj'><style id='pJLcj'><dir id='pJLcj'><q id='pJLcj'></q></dir></style></legend>

      <small id='pJLcj'></small><noframes id='pJLcj'>

    2. SecTrustEvaluate 始終使用 SecPolicyCreateSSL 返回 kSecT

      SecTrustEvaluate always returns kSecTrustResultRecoverableTrustFailure with SecPolicyCreateSSL(SecTrustEvaluate 始終使用 SecPolicyCreateSSL 返回 kSecTrustResultRecoverableTrustFailure)

          <small id='StJsW'></small><noframes id='StJsW'>

            <tbody id='StJsW'></tbody>
            <legend id='StJsW'><style id='StJsW'><dir id='StJsW'><q id='StJsW'></q></dir></style></legend>
              <bdo id='StJsW'></bdo><ul id='StJsW'></ul>
              <tfoot id='StJsW'></tfoot>

            • <i id='StJsW'><tr id='StJsW'><dt id='StJsW'><q id='StJsW'><span id='StJsW'><b id='StJsW'><form id='StJsW'><ins id='StJsW'></ins><ul id='StJsW'></ul><sub id='StJsW'></sub></form><legend id='StJsW'></legend><bdo id='StJsW'><pre id='StJsW'><center id='StJsW'></center></pre></bdo></b><th id='StJsW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='StJsW'><tfoot id='StJsW'></tfoot><dl id='StJsW'><fieldset id='StJsW'></fieldset></dl></div>
              • 本文介紹了SecTrustEvaluate 始終使用 SecPolicyCreateSSL 返回 kSecTrustResultRecoverableTrustFailure的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我的應用程序嘗試為自簽名證書評估服務器信任證書.這適用于 SecPolicyCreateBasicX509,但不適用于 SecPolicyCreateSSL

                My application tries to evaluate a server trust certificate for a self signed certificate. This is working fine with SecPolicyCreateBasicX509 but not working for SecPolicyCreateSSL

                這是我的代碼:

                if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) {
                        // create trust from protection space
                        SecTrustRef trustRef;
                        int trustCertificateCount = SecTrustGetCertificateCount(challenge.protectionSpace.serverTrust);
                
                        NSMutableArray* trustCertificates = [[NSMutableArray alloc] initWithCapacity:trustCertificateCount];
                        for (int i = 0; i < trustCertificateCount; i++) {
                            SecCertificateRef trustCertificate =  SecTrustGetCertificateAtIndex(challenge.protectionSpace.serverTrust, i);
                            [trustCertificates addObject:(id) trustCertificate];
                        }            
                
                        // set evaluation policy
                        SecPolicyRef policyRef;
                        // policyRef = SecPolicyCreateBasicX509(); this is working
                        policyRef = SecPolicyCreateSSL(NO, (CFStringRef)             
                        SecTrustCreateWithCertificates((CFArrayRef) trustCertificates, policyRef, &trustRef);
                
                        [trustCertificates release];
                
                        // load known certificates from keychain and set as anchor certificates
                        NSMutableDictionary* secItemCopyCertificatesParams = [[NSMutableDictionary alloc] init];    
                        [secItemCopyCertificatesParams setObject:(id)kSecClassCertificate forKey:(id)kSecClass];
                        [secItemCopyCertificatesParams setObject:@"Server_Cert_Label" forKey:(id)kSecAttrLabel];
                        [secItemCopyCertificatesParams setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnRef];
                        [secItemCopyCertificatesParams setObject:(id)kSecMatchLimitAll forKey:(id)kSecMatchLimit];
                
                        CFArrayRef certificates;
                        certificates = nil;
                        SecItemCopyMatching((CFDictionaryRef) secItemCopyCertificatesParams, (CFTypeRef*) &certificates);
                
                        if (certificates != nil && CFGetTypeID(certificates) == CFArrayGetTypeID()) {
                            SecTrustSetAnchorCertificates(trustRef, certificates);
                            SecTrustSetAnchorCertificatesOnly(trustRef, NO);
                        }
                
                        SecTrustResultType result;
                        OSStatus trustEvalStatus = SecTrustEvaluate(trustRef, &result);
                        if (trustEvalStatus == errSecSuccess) {
                            if (result == kSecTrustResultConfirm || result == kSecTrustResultProceed || result == kSecTrustResultUnspecified) {
                                // evaluation OK
                                [challenge.sender useCredential:[NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
                            } else {
                                // evaluation failed 
                                // ask user to add certificate to keychain
                        } else {
                            // evaluation failed - cancel authentication
                            [[challenge sender] cancelAuthenticationChallenge:challenge];
                        }
                }
                

                經過大量研究,我已經通過添加本文中提到的擴展名對自簽名證書進行了更改:無法信任 iphone 上的自簽名證書

                After a lot of research i have already made changes to the self-signed certificate by adding extension like mentioned in this post: Unable to trust a self signed certificate on iphone

                還有人提示這里可能缺少什么嗎?

                Does anyone have another hint what might be missing here?

                推薦答案

                經過大量測試,我已經解決了這個問題.以下內容已更改.

                After a lot of testing I have worked out this problem. The following has been changed.

                • 該策略設置為 NO 以進行服務器評估.這意味著檢查證書以進行客戶端身份驗證.顯然服務器證書不會有這個!將此設置為 YES 將實際檢查 extendedKeyUsage 是否為服務器證書設置為 serverAuth.

                • The policy is set to NO for server evaluation. This means the certificate is checked for client authentication. Obviously the server certificate will not have this! Setting this to YES will actually check if extendedKeyUsage is set to serverAuth for the server certificate.

                SecTrustSetAnchorCertificatesSecTrustSetAnchorCertificatesOnly 應始終在評估之前調用,而不僅僅是在您提供自己的錨證書時.您需要使用空數組調用它,否則系統已知的錨證書不會用于評估.即使從 MDM 安裝的受信任根證書也可以正常工作.

                SecTrustSetAnchorCertificates and SecTrustSetAnchorCertificatesOnly should always be called before evaluation and not only if you are providing your own anchor certificates. You need to call this with an empty array, otherwise the system known anchor certificates are not used for evaluation. Even installed trusted root certificates from MDM are working then.

                這是基于第一個代碼的工作示例:

                Here is a working sample based on the first code:

                if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) {
                    // create trust from protection space
                    SecTrustRef trustRef;
                    int trustCertificateCount = SecTrustGetCertificateCount(challenge.protectionSpace.serverTrust);
                
                    NSMutableArray* trustCertificates = [[NSMutableArray alloc] initWithCapacity:trustCertificateCount];
                    for (int i = 0; i < trustCertificateCount; i++) {
                        SecCertificateRef trustCertificate =  SecTrustGetCertificateAtIndex(challenge.protectionSpace.serverTrust, i);
                        [trustCertificates addObject:(id) trustCertificate];
                    }            
                
                    // set evaluation policy
                    SecPolicyRef policyRef;
                    // set to YES to verify certificate extendedKeyUsage is set to serverAuth
                    policyRef = SecPolicyCreateSSL(YES, (CFStringRef) challenge.protectionSpace.host);
                    SecTrustCreateWithCertificates((CFArrayRef) trustCertificates, policyRef, &trustRef);
                
                    [trustCertificates release];
                
                    // load known certificates from keychain and set as anchor certificates
                    NSMutableDictionary* secItemCopyCertificatesParams = [[NSMutableDictionary alloc] init];    
                    [secItemCopyCertificatesParams setObject:(id)kSecClassCertificate forKey:(id)kSecClass];
                    [secItemCopyCertificatesParams setObject:@"Server_Cert_Label" forKey:(id)kSecAttrLabel];
                    [secItemCopyCertificatesParams setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnRef];
                    [secItemCopyCertificatesParams setObject:(id)kSecMatchLimitAll forKey:(id)kSecMatchLimit];
                
                    CFArrayRef certificates;
                    certificates = nil;
                    SecItemCopyMatching((CFDictionaryRef) secItemCopyCertificatesParams, (CFTypeRef*) &certificates);
                
                    if (certificates != nil && CFGetTypeID(certificates) == CFArrayGetTypeID()) {
                        SecTrustSetAnchorCertificates(trustRef, certificates);
                        SecTrustSetAnchorCertificatesOnly(trustRef, NO);
                    } else {
                        // set empty array as own anchor certificate so system anchos certificates are used too!
                        SecTrustSetAnchorCertificates(trustRef, (CFArrayRef) [NSArray array]);
                        SecTrustSetAnchorCertificatesOnly(trustRef, NO);
                    }
                
                    SecTrustResultType result;
                    OSStatus trustEvalStatus = SecTrustEvaluate(trustRef, &result);
                    if (trustEvalStatus == errSecSuccess) {
                        if (result == kSecTrustResultConfirm || result == kSecTrustResultProceed || result == kSecTrustResultUnspecified) {
                            // evaluation OK
                            [challenge.sender useCredential:[NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
                        } 
                        else {
                            // evaluation failed 
                            // ask user to add certificate to keychain
                        }
                    } 
                    else {
                        // evaluation failed - cancel authentication
                        [[challenge sender] cancelAuthenticationChallenge:challenge];
                    }
                }
                

                希望這會對某人有所幫助.

                Hope this will help someone.

                這篇關于SecTrustEvaluate 始終使用 SecPolicyCreateSSL 返回 kSecTrustResultRecoverableTrustFailure的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                To stop segue and show alert(停止 segue 并顯示警報)
                iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                Icon already includes gloss effects(圖標已經包含光澤效果)
                How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))

              • <small id='ngptI'></small><noframes id='ngptI'>

                <tfoot id='ngptI'></tfoot>
                <legend id='ngptI'><style id='ngptI'><dir id='ngptI'><q id='ngptI'></q></dir></style></legend>
                  <bdo id='ngptI'></bdo><ul id='ngptI'></ul>

                      • <i id='ngptI'><tr id='ngptI'><dt id='ngptI'><q id='ngptI'><span id='ngptI'><b id='ngptI'><form id='ngptI'><ins id='ngptI'></ins><ul id='ngptI'></ul><sub id='ngptI'></sub></form><legend id='ngptI'></legend><bdo id='ngptI'><pre id='ngptI'><center id='ngptI'></center></pre></bdo></b><th id='ngptI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ngptI'><tfoot id='ngptI'></tfoot><dl id='ngptI'><fieldset id='ngptI'></fieldset></dl></div>

                            <tbody id='ngptI'></tbody>

                          主站蜘蛛池模板: 在线播放精品视频 | 天天操妹子 | 一区二区片 | 国产成人精品免费 | 美女国内精品自产拍在线播放 | 亚洲久久久 | 黄片毛片在线观看 | 欧美一区中文字幕 | 男女啪啪高潮无遮挡免费动态 | 精品一区二区久久久久久久网站 | 中文字幕高清在线 | 99久热在线精品视频观看 | 色婷婷精品久久二区二区蜜臂av | 99精品久久 | 亚洲欧美日韩在线 | 国产乱码久久久久久 | 久久伊人影院 | 午夜丰满寂寞少妇精品 | 凹凸日日摸日日碰夜夜 | 午夜影院免费体验区 | 欧美伊人久久久久久久久影院 | 精品国产91乱码一区二区三区 | 在线观看精品 | 国产不卡一 | 偷拍自拍网站 | 亚洲欧美日韩精品久久亚洲区 | 午夜一区二区三区视频 | 国产一级视频在线播放 | 91性高湖久久久久久久久_久久99 | 黄色网毛片 | 2018天天干天天操 | 国产超碰人人爽人人做人人爱 | 草草网| 中文字幕第九页 | 亚洲成人中文字幕 | 在线播放亚洲 | 国产 欧美 日韩 一区 | 久久国产精品视频 | 久久久久久国产精品免费免费狐狸 | 精品国产一区二区在线 | 欧美综合在线视频 |