Skip to content

Support Certificate Pinning #228

@tsorencraig

Description

@tsorencraig

Public key pinning is a great step for apps to reduce MITM vulnerabilities. The current instantiation of the Apollo Client allows a parameter for the URLSession configuration. In order to implement SSL pinning, however, an entire URLSession object should be able to be passed in. This would allows the URLSession object to register a delegate that handles the pinning by implementing

optional public func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Swift.Void)

This can be done simply by adding another constructor to the HttpNetworkTransport object that accepts the URLSession object instead of just it's configuration.

After that, injecting the session object with the appropriate delegate is simple.

let configuration = URLSessionConfiguration.default
        
let networkTransport = HTTPNetworkTransport(url: "https://some-gql-endpoint/graphql",
                                            session: URLSession(configuration: configuration,
                                                                                delegate: NSURLSessionPinningDelegate(),
                                                                                delegateQueue: nil))

let client = ApolloClient(networkTransport: networkTransport)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIssues outlining new things we want to do or things that will make our lives as devs easier

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions