Class

URLCredential

NSURLCredential is an immutable object representing an authentication credential consisting of authentication information specific to the type of credential and the type of persistent storage to use, if any.

Overview

The URL loading system supports three types of credentials: password-based user credentials, certificate-based user credentials, and certificate-based server credentials (used when verifying the server’s identity).

When you create a credential, you can specify that it should be used for a single request, persisted temporarily (until your app quits), or persisted permanently (in the keychain).

Nested Types

URLCredential.Persistence

These constants specify how long the credential will be kept.

Symbols

Creating a credential

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

Returns an NSURLCredential object for client certificate authentication initialized with a given identity and a given array of client certificates using a given persistence setting.

init(trust: SecTrust)

Returns an NSURLCredential object for server trust authentication initialized with a given accepted trust.

init(user: String, password: String, persistence: URLCredential.Persistence)

Returns an NSURLCredential object initialized with a given user name and password using a given persistence setting.

Getting credential properties

var user: String?

The receiver’s user name.

var certificates: [Any]

The certificates of the credential, if it is a client certificate credential.

var hasPassword: Bool

A Boolean value that indicates whether the receiver has a password.

var password: String?

The receiver’s password.

var identity: SecIdentity?

The identity of this credential if it is a client certificate credential.

var persistence: URLCredential.Persistence

The receiver’s persistence setting.

Constants

URLCredential.Persistence

These constants specify how long the credential will be kept.

Relationships

Inherits From