Instance Method

initWithTrust:

Creates a URL credential instance for server trust authentication, initialized with a accepted trust.

Declaration

- (instancetype)initWithTrust:(SecTrustRef)trust;

Parameters

trust

The accepted trust.

Return Value

A new URL credential object, containing the provided server trust.

Discussion

Before your implementation of URLSession:task:didReceiveChallenge:completionHandler: uses this initializer to create a server trust credential, you are responsible for evaluating the received SecTrustRef instance. You get this serverTrust from the protectionSpace of the NSURLAuthenticationChallenge parameter that is passed to your delegate method. Pass the trust instance to SecTrustEvaluate to evaluate it. If this call indicates the trust is invalid, you should cancel the challenge by passing the NSURLSessionAuthChallengeCancelAuthenticationChallenge disposition to the completion handler.

See Also

Creating a Credential

+ credentialForTrust:

Creates a URL credential instance for server trust authentication with a given accepted trust.

+ credentialWithUser:password:persistence:

Creates a URL credential instance for internet password authentication with a given user name and password, using a given persistence setting.

+ credentialWithIdentity:certificates:persistence:

Creates a URL credential instance for resolving a client certificate authentication challenge.

- initWithIdentity:certificates:persistence:

Creates a URL credential instance for resolving a client certificate authentication challenge.

- initWithUser:password:persistence:

Creates a URL credential instance initialized with a given user name and password, using a given persistence setting.

NSURLCredentialPersistence

Constants that specify how long the credential will be kept.