---
title: "certificateValidator(_:)"
framework: network
role: symbol
role_heading: Instance Method
path: "network/tls/certificatevalidator(_:)"
---

# certificateValidator(_:)

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

## Declaration

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

## Discussion

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.
