<!--
{
  "availability" : [
    "macOS: 10.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLDownloadDelegate/download(_:canAuthenticateAgainstProtectionSpace:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLDownloadDelegate(im)download:canAuthenticateAgainstProtectionSpace:"
  },
  "title" : "download(_:canAuthenticateAgainstProtectionSpace:)"
}
-->

# download(_:canAuthenticateAgainstProtectionSpace:)

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

```
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

This method is called before [`download(_:didReceive:)`](/documentation/Foundation/NSURLDownloadDelegate/download(_:didReceive:)-1pc0v), allowing the delegate to inspect a protection space before attempting to authenticate against it. By returning <doc://com.apple.documentation/documentation/Swift/true>, the delegate indicates that it can handle the form of authentication, which it does in the subsequent call to [`download(_:didReceive:)`](/documentation/Foundation/NSURLDownloadDelegate/download(_:didReceive:)-1pc0v). Not implementing this method is the same as returning <doc://com.apple.documentation/documentation/Swift/false>, in which case default authentication handling is used.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)