3

NSURLCredentialStorage保存した直後に認証情報を取得しようとしても、から認証情報を取得できないという問題が発生しています。

資格情報は適切にフォーマットされており、サーバーによって受け入れられ、永続的に設定されています。資格情報に ID と証明書があることを印刷して確認するためのデバッグ コードがあります。ただし、資格情報ストレージから取得しようとすると、デバッグによってすべての値が Null として出力されますが、資格情報自体は null ではありません。

NSURLCredentialStorage から資格情報を適切に取得するにはどうすればよいですか?

-(void)saveCredential:(NSURLCredential*)credential forProtectionSpace:(NSURLProtectionSpace*)protectionSpace
{

    CLog(@"ATTEMPTING SAVE:");
    [self debugCredential:credential]; //credential is properly formatted

    [[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential
                                          forProtectionSpace:protectionSpace];


    NSURLCredential* retrievedTest = [[NSURLCredentialStorage sharedCredentialStorage]defaultCredentialForProtectionSpace:protectionSpace];

    CLog(@"ATTEMPTING RETRIEVAL:");
    [self debugCredential:retrievedTest]; //all values are null, credential is not null

}

-(void)debugCredential:(NSURLCredential*) credential
{

    CLog(@"DEBUG Credential: [%@]",credential);
    CLog(@"credential identity: %@", credential.identity);
    CLog(@"credential cert: %@", credential.certificates);
    CLog(@"credential persistence: %lu", (unsigned long)credential.persistence);
}

保存前後のログはこちら

//before save
2016-02-17 16:24:19.669 GWNMobile[2925:716139] DEBUG Credential: [<NSURLCredential: 0x16ff6c00>: (null)]
2016-02-17 16:24:19.670 GWNMobile[2925:716139] credential identity: <SecIdentityRef: 0x16e24890>
2016-02-17 16:24:19.670 GWNMobile[2925:716139] credential cert: (
    "<cert(0x16f9c750) s: [Name] i: [Issuer]>"
)
2016-02-17 16:24:19.670 GWNMobile[2925:716139] credential persistence: 2

//after retrieval:
2016-02-17 16:24:19.670 GWNMobile[2925:716139] ==========================
2016-02-17 16:24:19.691 GWNMobile[2925:716139] ATTEMPTING RETRIEVAL:
2016-02-17 16:24:19.691 GWNMobile[2925:716139] DEBUG Credential: [(null)]
2016-02-17 16:24:19.691 GWNMobile[2925:716139] credential identity: (null)
2016-02-17 16:24:19.691 GWNMobile[2925:716139] credential cert: (null)
2016-02-17 16:24:19.691 GWNMobile[2925:716139] credential persistence: 0
4

0 に答える 0