<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Network",
  "identifier" : "/documentation/Network/DTLS/certificateValidator(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "s:7Network4DTLSV20certificateValidatoryACSbSo24OS_sec_protocol_metadata_p_So0e1_F6_trust_ptYaYbYAcF"
  },
  "title" : "certificateValidator(_:)"
}
-->

# certificateValidator(_:)

Set a closure to provide custom verification of the peer’s credentials during the DTLS handshake.

```
func certificateValidator(_ handler: @escaping @isolated(any) @Sendable (sec_protocol_metadata_t, sec_trust_t) async -> Bool) -> DTLS
```

## Discussion

This closure may be called multiple times for each connection. It should return `true` if
the credentials should be trusted and the handshake should proceed, `false` otherwise.

> Warning: Most apps should not override the default system handling,
> as doing so can result in insecure network connections and major security vulnerabilities.

---

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)