Instance Method

session:didReceiveCertificate:fromPeer:certificateHandler:

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

Declaration

- (void)session:(MCSession *)session didReceiveCertificate:(NSArray *)certificate fromPeer:(MCPeerID *)peerID certificateHandler:(void (^)(BOOL accept))certificateHandler;

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 initWithPeer: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 YES if the nearby peer should be allowed to join the session, or NO 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 YES (to trust the nearby peer) or NO (to reject it).

For information about validating certificates, read Cryptographic Services Guide.

See Also

MCSession Delegate Methods

- session:didReceiveData:fromPeer:

Indicates that an NSData object has been received from a nearby peer.

Required.

- session:didStartReceivingResourceWithName:fromPeer:withProgress:

Indicates that the local peer began receiving a resource from a nearby peer.

Required.

- session:didFinishReceivingResourceWithName:fromPeer:atURL:withError:

Indicates that the local peer finished receiving a resource from a nearby peer.

Required.

- session:didReceiveStream:withName:fromPeer:

Called when a nearby peer opens a byte stream connection to the local peer.

Required.

- session:peer:didChangeState:

Called when the state of a nearby peer changes.

Required.