<!--
{
  "availability" : [
    "iOS: 7.0.0 - 27.0.0",
    "iPadOS: 7.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.10.0 - 27.0.0",
    "tvOS: 10.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MultipeerConnectivity",
  "identifier" : "/documentation/MultipeerConnectivity/MCSessionDelegate/session(_:didReceiveCertificate:fromPeer:certificateHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Multipeer Connectivity"
    ],
    "preciseIdentifier" : "c:objc(pl)MCSessionDelegate(im)session:didReceiveCertificate:fromPeer:certificateHandler:"
  },
  "title" : "session(_:didReceiveCertificate:fromPeer:certificateHandler:)"
}
-->

# session(_:didReceiveCertificate:fromPeer:certificateHandler:)

Called to validate the client certificate provided by a peer when the connection is first established.

```
optional func session(_ session: MCSession, didReceiveCertificate certificate: [Any]?, fromPeer peerID: MCPeerID, certificateHandler: @escaping (Bool) -> Void)
```

## Parameters

`session`

The session that the nearby peer wishes to join.

`certificate`

A certificate chain, presented as an array of SecCertificateRef certificate objects. The first certificate in this chain is the peer’s certificate, which is derived from the identity that the peer provided when it called the [`init(peer:securityIdentity:encryptionPreference:)`](/documentation/MultipeerConnectivity/MCSession/init(peer:securityIdentity:encryptionPreference:)) method. The other certificates are the (optional) additional chain certificates provided in that same array.

    If the nearby peer did not provide a security identity, then this parameter’s value is     `nil`    .

`peerID`

The peer ID of the sender.

`certificateHandler`

Your app should call this handler with a value of <doc://com.apple.documentation/documentation/Swift/true> if the nearby peer should be allowed to join the session, or <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

Your app should inspect the nearby peer’s certificate, and then should decide whether to trust that certificate. Upon making that determination, your app should call the provided `certificateHandler` block, passing either <doc://com.apple.documentation/documentation/Swift/true> (to trust the nearby peer) or <doc://com.apple.documentation/documentation/Swift/false> (to reject it).

For information about validating certificates, read [Cryptographic Services Guide](https://developer.apple.com/library/archive/documentation/Security/Conceptual/cryptoservices/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011172).

> Important:
> The multipeer connectivity framework makes no attempt to validate the peer-provided identity or certificates in any way. If your delegate does not implement this method, all certificates are accepted automatically.

---

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)