Contents

init(identity:certificates:persistence:)

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

Declaration

init(identity: SecIdentity, certificates certArray: [Any]?, persistence: URLCredential.Persistence)

Parameters

  • identity:

    The identity for the credential.

  • certArray:

    An array of one or more SecCertificateRef objects representing intermediate certificates leading from the identity’s certificate to a trusted root, or nil if the server does not need any intermediate certificates to authenticate the client.

  • persistence:

    The method ignores this parameter; you should supply a value of Forsession because that most accurately reflects the actual behaviour.

Return Value

A new URL credential object, using the provided identity and, optionally, an array of intermediate certificates.

Discussion

When you receive a client certificate authentication challenge (NSURLAuthenticationMethodClientCertificate) and want to resolve it successfully, you must supply a credential created using this initializer.

In most cases you should pass nil to the certArray parameter. You only need to supply an array of intermediate certificates if the server needs those intermediate certificates to authenticate the client. Typically this isn’t necessary because the server already has a copy of the relevant intermediate certificates.

See Also

Creating a credential