---
title: MEMessageSecurityHandler
framework: mailkit
role: symbol
role_heading: Protocol
path: mailkit/memessagesecurityhandler
---

# MEMessageSecurityHandler

An object that digitally signs or encrypts messages the user sends and receives.

## Declaration

```swift
@MainActor protocol MEMessageSecurityHandler : MEMessageDecoder, MEMessageEncoder
```

## Overview

Overview When users enable an extension that implements a message security handler, Mail passes incoming and outgoing message content to the extension for encryption and digital signing. To encompass the symmetrical halves for encoding and decoding, MailKit defines two protocols that MEMessageSecurityHandler conforms to: As the user composes a mail message, MailKit calls getEncodingStatus(for:composeContext:completionHandler:) to determine if the handler can sign or encrypt the message. The handler indicates the capabilities by providing an instance of MEOutgoingMessageEncodingStatus. Mail reflects this status in the compose window by enabling the appropriate buttons to let the user choose how to encode the message. When the user sends the message, MailKit invokes the encode(_:composeContext:completionHandler:) method, and indicates whether the user chose to encrypt or sign the message. When MailKit needs the original message content, it invokes the handler’s decodedMessage(forMessageData:) method. This method creates an instance of MEDecodedMessage that includes the raw decoded message data and the details of who signed the message in an instance of MEMessageSecurityInformation. note: MailKit stores the encrypted and signed message content. Therefore, MailKit may ask a message security handler to decode the same message repeatedly over time when it needs the decoded original message content. To indicate that your extension contains a message security handler, add MEMessageSecurityHandler to the MEExtensionCapabilities array in the extension’s Info.plist file: <key>NSExtensionAttributes</key> <dict>     <key>MEExtensionCapabilities</key>     <array>         <string>MEMessageSecurityHandler</string>     </array> </dict>

## Topics

### Encrypting and Signing Messages

- [MEMessageEncoder](mailkit/memessageencoder.md)
- [MEEncodedOutgoingMessage](mailkit/meencodedoutgoingmessage.md)
- [MEOutgoingMessageEncodingStatus](mailkit/meoutgoingmessageencodingstatus.md)
- [MEMessageEncodingResult](mailkit/memessageencodingresult.md)

### Decrypting Messages and Verifying Signatures

- [MEMessageDecoder](mailkit/memessagedecoder.md)
- [MEDecodedMessage](mailkit/medecodedmessage.md)
- [MEMessageSigner](mailkit/memessagesigner.md)
- [MEMessageSecurityInformation](mailkit/memessagesecurityinformation.md)

### Displaying Signature Details

- [extensionViewController(signers:)](mailkit/memessagesecurityhandler/extensionviewcontroller(signers:).md)

### Instance Methods

- [extensionViewController(messageContext:)](mailkit/memessagesecurityhandler/extensionviewcontroller(messagecontext:).md)
- [primaryActionClicked(forMessageContext:completionHandler:)](mailkit/memessagesecurityhandler/primaryactionclicked(formessagecontext:completionhandler:).md)

## Relationships

### Inherits From

- [MEMessageDecoder](mailkit/memessagedecoder.md)
- [MEMessageEncoder](mailkit/memessageencoder.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
