---
title: DCError.Code.invalidKey
framework: DeviceCheck
role: symbol
role_heading: Case
platforms: [iOS 11.0+, iPadOS 11.0+, Mac Catalyst 13.1+, macOS 10.15+, tvOS 11.0+, visionOS 1.0+, watchOS 9.0+]
path: devicecheck/dcerror-swift.struct/code/invalidkey
---

# DCError.Code.invalidKey

An error caused by a failed attempt to use the App Attest key.

## Declaration

```swift
case invalidKey
```

## Discussion

Discussion You receive this error if something goes wrong with generating, retrieving, or using an App Attest cryptographic key, when: You call attestKey(_:clientDataHash:completionHandler:) for a key that’s already been attested. You call generateAssertion(_:clientDataHash:completionHandler:) with an unattested key. The App Attest service cannot enforce the key access control policy on macOS. The App Attest service rejects the key.

## See Also

### Error codes

- [DCError.Code.featureUnsupported](devicecheck/dcerror-swift.struct/code/featureunsupported.md)
- [DCError.Code.invalidInput](devicecheck/dcerror-swift.struct/code/invalidinput.md)
- [DCError.Code.serverUnavailable](devicecheck/dcerror-swift.struct/code/serverunavailable.md)
- [DCError.Code.unknownSystemFailure](devicecheck/dcerror-swift.struct/code/unknownsystemfailure.md)
