A server or an area on a server, commonly referred to as a realm, that requires authentication.


A protection space defines a series of matching constraints that determine which credential should be provided. For example, if a request provides your delegate with an URLAuthenticationChallenge object that requests a client username and password, your app should provide the correct username and password for the particular host, port, protocol, and realm, as specified in the challenge’s protection space.


Creating a protection space

Getting protection space properties

var authenticationMethod: String

The authentication method used by the receiver.

var distinguishedNames: [Data]?

The acceptable certificate-issuing authorities for client certificate authentication.

var host: String

The receiver’s host.

var port: Int

The receiver’s port.

var `protocol`: String?

The receiver’s protocol.

var proxyType: String?

The receiver's proxy type.

var realm: String?

The receiver’s authentication realm

var receivesCredentialSecurely: Bool

A boolean value that indicates whether the credentials for the protection space can be sent securely.

var serverTrust: SecTrust?

A representation of the server’s SSL transaction state.


NSURLProtectionSpace Protocol Types

These constants describe the supported protocols for a protection space, as returned by protocol.

NSURLProtectionSpace Proxy Types

These constants describe the supported proxy types used in init(proxyHost:port:type:realm:authenticationMethod:) and returned by proxyType.

Instance Methods


Inherits From

See Also

Authentication and Credentials

Handling an Authentication Challenge

Respond appropriately when a server demands authentication for a URL request.

class URLAuthenticationChallenge

A challenge from a server requiring authentication from the client.

class URLCredential

An authentication credential consisting of authentication information specific to the type of credential and the type of persistent storage to use, if any.

class URLCredentialStorage

An object that manages the credential storage.