---
title: "download(_:canAuthenticateAgainstProtectionSpace:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurldownloaddelegate/download(_:canauthenticateagainstprotectionspace:)"
---

# download(_:canAuthenticateAgainstProtectionSpace:)

Sent to determine whether the delegate is able to respond to a protection space’s form of authentication.

## Declaration

```swift
optional func download(_ connection: NSURLDownload, canAuthenticateAgainstProtectionSpace protectionSpace: URLProtectionSpace) -> Bool
```

## Parameters

- `connection`: The download sending the message.
- `protectionSpace`: The protection space that generates an authentication challenge.

## Discussion

Discussion This method is called before download(_:didReceive:), allowing the delegate to inspect a protection space before attempting to authenticate against it. By returning true, the delegate indicates that it can handle the form of authentication, which it does in the subsequent call to download(_:didReceive:). Not implementing this method is the same as returning false, in which case default authentication handling is used.

## See Also

### Download Authentication

- [download(_:didCancel:)](foundation/nsurldownloaddelegate/download(_:didcancel:).md)
- [download(_:didReceive:)](foundation/nsurldownloaddelegate/download(_:didreceive:)-1pc0v.md)
- [downloadShouldUseCredentialStorage(_:)](foundation/nsurldownloaddelegate/downloadshouldusecredentialstorage(_:).md)
