4

ベータ版で動作しないという報告を受けた後、iOS5にアプリケーションを更新する必要があります。この問題は、カスタムSSL証明書の検証が機能しなくなったという事実にまでさかのぼります。

didReceiveAuthenticationChallengeセクションで、ルート証明書を取得し、SecTrustEvaluateを呼び出します。これはiOS4で正常に機能します。

protectionSpace = [challenge protectionSpace];
    trust = [protectionSpace serverTrust];

    err = SecTrustEvaluate(trust, &trustResult);

    trusted = (err == noErr) && ((trustResult == kSecTrustResultProceed) || (trustResult == kSecTrustResultUnspecified));

    if (!trusted) { 
        err = SecTrustSetAnchorCertificates(trust, (CFArrayRef)[EagleAccessAppDelegate getDelegate].rootCertificates);

        if (err == noErr) {
            err = SecTrustEvaluate(trust, &trustResult);
        }

        trusted = (err == noErr) && ((trustResult == kSecTrustResultProceed) || (trustResult == kSecTrustResultUnspecified));
    }

    if (trusted) { 
        NSURLCredential *cred = [NSURLCredential credentialForTrust:trust];
        [[challenge sender] useCredential:cred forAuthenticationChallenge:challenge];
    } else { 
        [[challenge sender] cancelAuthenticationChallenge:challenge];
    }

証明書は、アプリケーションに含まれるリソースとしてDER形式で保存されます。

// Load Certificates. 
NSString *devFilePath = [[NSBundle mainBundle] pathForResource:@"ipms-dev-ca.der" ofType:@"crt"];  
NSData *devRootCertificate = [[[NSData alloc] initWithContentsOfFile:devFilePath] autorelease];
SecCertificateRef devRoot = SecCertificateCreateWithData(NULL, (CFDataRef) devRootCertificate);

NSString *prodFilePath = [[NSBundle mainBundle] pathForResource:@"ipms-prod-ca.der" ofType:@"crt"];  
NSData *prodRootCertificate = [[[NSData alloc] initWithContentsOfFile:prodFilePath] autorelease];
SecCertificateRef prodRoot = SecCertificateCreateWithData(NULL, (CFDataRef) prodRootCertificate);

self.rootCertificates = [[NSArray alloc] initWithObjects:(id)devRoot, (id)prodRoot, nil];

基本的に、アプリが接続するサーバーの証明書を発行するために使用する独自のCA証明書があります。

AdvancedURLConnectionsサンプルアプリケーションを使用してこれを再作成できます。

4

1 に答える 1

4

問題は、証明書がMD5署名であったことでした。これらの署名は、iOS5ではサポートされなくなりました。

于 2011-09-15T22:49:52.910 に答える