相关疑难解决方法(0)

iOS:在密钥链中预先安装SSL证书 - 以编程方式

我想在用户访问网站之前在钥匙串中安装/保存证书.我有一个HTTPS服务器,我的应用程序在访问https:// mysite之前对用户进行了身份验证.有没有办法可以通过钥匙串中的邮政请求安装/保存证书.或者我将该证书(文件)复制到资源包以将其标记为受信任.

谢谢

ssl install certificate keychain ios

18
推荐指数
2
解决办法
2万
查看次数

使用NSURLConnection和NSURLProtectionSpace确定信任

我想问一个先前提出的问题的后续问题.我已经有了创建NSURLRequest/Connection的代码,运行它并调用了用于身份验证的回调方法.这是具体的代码:

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
    return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust] || [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodDefault];
}

-(void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{   

    if ([challenge previousFailureCount] > 0) {
        [[challenge sender] cancelAuthenticationChallenge:challenge];
        NSLog(@"Bad Username Or Password");
        badUsernameAndPassword = YES;
        finished = YES;
        return;
    }

    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
    {
        if (appDelegate._allowInvalidCert)
        {
            // Go ahead...trust me!
            [challenge.sender useCredential:
             [NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust] 
                 forAuthenticationChallenge: challenge];
        }
        else
        {
            TrustGenerator *tg = [[TrustGenerator alloc] init];

            if ([tg getTrust:challenge.protectionSpace])
            {
                // Go ahead...trust me!
                [challenge.sender …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch certificate nsurlconnection ios

14
推荐指数
1
解决办法
1万
查看次数

在iOS上查找证书

请注意,这个问题是在2001年被问到的.情况发生了变化.

我有一个需要访问Junos VPN的iOS设备.从管理的Junos不透明的指示说,我要检索已供应给使用苹果IPCU设备的证书.我知道证书是设备上(我可以看到它在设置),虽然邮件,Safari和基于Junos应用程序,我可以访问VPN.

Apple文档声明每个应用程序都有自己的钥匙串,但这三个应用程序都可以看到证书.Jusos可以访问IPCU提供的证书,这意味着任何应用都可以访问此证书.但是,当我尝试找到它时:

    CFTypeRef   certificateRef = NULL;                                                  // will hold a ref to the cert we're trying to retrieve
const char *certLabelString = "myCertificateName";                                      // c string of the certificate we're searching for.
CFStringRef certLabel = CFStringCreateWithCString( NULL, certLabelString, kCFStringEncodingUTF8); // the search we need - a string match for a UTF8 String.

const void *keys[] =   { kSecClass, kSecAttrLabel, kSecReturnRef };
const void *values[] = { kSecClassCertificate, certLabel, kCFBooleanTrue };
CFDictionaryRef dict = CFDictionaryCreate(NULL, keys, values, 3, NULL, …
Run Code Online (Sandbox Code Playgroud)

certificate keychain ios

9
推荐指数
1
解决办法
1万
查看次数