<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "OpenSSL",
  "identifier" : "/documentation/OpenSSL/OpenSSLError/invalidKey(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "OpenSSL"
    ],
    "preciseIdentifier" : "s:7OpenSSL0A8SSLErrorO10invalidKeyyACSScACmF"
  },
  "title" : "OpenSSLError.invalidKey(_:)"
}
-->

# OpenSSLError.invalidKey(_:)

Thrown when PEM key material fails ingestion.

```
case invalidKey(String)
```

## Discussion

Produced by [`init(pemRepresentation:)`](/documentation/OpenSSL/RSA/PrivateKey/init(pemRepresentation:)) and
[`init(pemRepresentation:)`](/documentation/OpenSSL/RSA/PublicKey/init(pemRepresentation:)) when the input is not
valid UTF-8 or does not contain the expected `-----BEGIN ... KEY-----`
frame. The associated `String` describes which check failed.

Typical remediation: confirm the string was read from disk with the
correct encoding (UTF-8, not UTF-16 with BOM) and that the file has
not been truncated or line-ending-mangled by a text editor.