Skip to content

Adding a certificate authentication request #251

@owenhartnett

Description

@owenhartnett

I'm trying to hit a server which sits in the dmz and asks for a certificate. It sends out a challenge in the initial http request. I supply the certificate for the NSURLSession. The code I use for AFNetworking on my REST calls to send the cert is here:

 [manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(NSURLSession * _Nonnull session, NSURLAuthenticationChallenge * _Nonnull challenge, NSURLCredential *__autoreleasing  _Nullable * _Nullable credential) {
        id sender = [challenge sender];
        const void *certArray[] = { certificate };
        CFArrayRef myCerts = CFArrayCreate(NULL, (void *) certArray, 1, NULL);     
        *credential = [NSURLCredential credentialWithIdentity: ident certificates: (__bridge NSArray *) myCerts persistence: NSURLCredentialPersistencePermanent];
        [sender useCredential:*credential forAuthenticationChallenge:challenge];
        CFRelease(myCerts);
        return NSURLSessionAuthChallengeUseCredential;
    }];

Is it possible to send this through the SwiftPhoenix client and, if so, where is the point where I could insert it? I know websocket makes an initial http call to connect, and I'm looking for that particular point in the code (I'm assuming it's using a NSURLSession to connect!)

I don't think the above is certificate pinning, but I could be wrong.

Thanks for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions