> For the complete documentation index, see [llms.txt](https://www.x509.wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.x509.wiki/important-data-formats/pkcs-7.md). Agents can also search and read this documentation through its [MCP server](https://www.x509.wiki/~gitbook/mcp).

# PKCS#7

PKCS#7 is the Swiss Army Knife in cryptographic data formats and it may contain virtually anything -- encrypted messages, signed messages, signed and encrypted messages, certificates, and private keys

PKCS#7 is part of the Public Key Cryptographic Standards. You might have guessed it, but it is the seventh of these standards. Its successor [CMS](https://www.rfc-editor.org/rfc/rfc5652) is mostly backwards compatible and therefore other dependant standards may refer to either PKCS#7 or CMS, depending on their own version. Therefore, we sometimes use the PKCS#7 and CMS interchangeably on this site.

This is also the major disadvantage of this format. If an application or user gets a PKCS#7, it is not by itself clear what to do with it. Here are some important use cases:

* S/MIME messages are basically emails with PKCS#7 bodies or attachments.
* [SCEP ](https://www.x509.wiki/enrollment-methods/scep.md)requests and replies are both actually PKCS#7 signed messages.
* EST responses are CMS messages.

### Encoding

Common file endings are .p7b ([DER encoded](https://www.x509.wiki/important-data-formats/asn.1-and-pem.md#der-encoding)), .p7s (a signed message or message signature), and .p7m (a signed and/or encrypted message). The [PEM-encoding](https://www.x509.wiki/important-data-formats/asn.1-and-pem.md#pem-encoding) with label "PKCS7" is also defined, but seldom used.

### Tools

In Windows, you can open PKCS#7 messages with a double click and the Crypto-shell extensions will display it for you. However, you can usually only extract certificates and their private keys out of it, and not message contents.

You can convert these files into other formats with tools like OpenSSL.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.x509.wiki/important-data-formats/pkcs-7.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
