Blog
A P7M file will not open
If a .p7m will not open: wrong program, Base64, a truncated file, a double envelope, PEC or encrypted content. How to tell the causes apart.
- Published
- Updated
You downloaded a .p7m, double-clicked, and got an error, a blank page or a “damaged” PDF. The cause is almost always one of a few. This guide puts them in order, from the one that does not need a new file to the one that means writing back to the sender. Use Lettore P7M as the test. The message you see is already a diagnosis, because the program looks at the content and not at the name.
The computer has no suitable program
This is the most frequent case and it does not mean a broken file. Windows, macOS, Android and iPhone do not associate .p7m with a CAdES envelope reader. Preview and the PDF viewer stop because the first bytes are not %PDF.
What to do: open the reader in the browser and select the file, or drag it onto the page. On a Mac, do not associate the extension with Safari. That would open the raw envelope. The steps by system are in the guides for Mac and Android and iPhone.
The file is Base64 or PEM text
Open a copy in a text editor. If you see a long sequence of letters and numbers, the envelope is textual.
The reader accepts three situations.
- Binary CMS, the normal case produced by signature software.
- PEM, if the text contains
-----BEGIN PKCS7-----,-----BEGIN CMS-----or-----BEGIN SIGNED DATA-----, closed by the matching END label. - Standard Base64 of the whole file: the alphabet
A-Z,a-z,0-9,+,/and=, with correct padding. After decoding, the bytes must start as a CMS structure.
It does not accept url-safe Base64, in which + and / are replaced by - and _. In that case the message is the same as for a file that is not a P7M. Do not try changing only the extension. If you can, ask the sender for the original binary envelope, or convert that text to standard Base64 with a local tool you trust, without sending the document to an unknown site.
The extension does not count. A .txt that contains a valid envelope opens. A .p7m that contains something else does not.
Incomplete download, changed name, encrypted file
Compare the size with the one stated in the message. If it is smaller, the attachment is truncated. The reader may report a damaged or incomplete file. Download it again from webmail. If the result does not change, ask for a new sending. There is no serious repair of an envelope cut in half.
A real PDF starts, in the clear, with %PDF. If your “p7m” starts that way, it is a renamed PDF. Put it back to .pdf and open it with a PDF reader. Do not insist with the envelope reader. The other way round, a .p7m renamed .pdf can still be selected in the reader, because the extension is ignored.
If the message speaks of an encrypted file, the envelope is for a recipient and needs that person’s key. It is not a signature to “unlock” with a license. If it speaks of a detached signature, the original document is missing from the envelope. You also need the separate file the signature refers to.
The size limit is 100 MB. A larger file is refused with an explicit message, not with a partial preview. Above 50 MB a warning appears. Close other tabs and try again.
A double extension and the wrong PEC attachment
contratto.pdf.p7m.p7m is an envelope inside another. A tool that opens only the first layer gives you another .p7m and seems unfinished. The reader shows the layers separately and does not collapse them into one PDF. Countersignatures stay unverified. If there are too many layers, the error says the nested signatures are beyond the limit. Do not force the result open and do not rename it.
In PEC (Italian certified email) it is easy to pick the wrong file. smime.p7s is the provider’s signature on the transport envelope. daticert.xml contains the message certification data. Neither is the contract. Save the .p7m that sits in the original message, postacert.eml. The procedure is in the guide to P7M attachments in PEC.
The envelope opens, but the result is not “all clear”
This is not an opening problem. The document can be read and the checks must be interpreted.
- Integrity not confirmed: do not treat the content as matching the signature.
- Expired certificate: the date claimed by the signer does not, on its own, prove that the signature was valid in the past.
- Revocation unavailable: a usable proof is missing, often because of the network or an issuer service. It is not a clearance.
- A statement that revocation came before the signature: it appears only if verified time evidence is later than the revocation. Without that proof, the reader does not turn a claimed date into a historical fact.
The results are explained in Expired or revoked signature. The reader does not block reading because of revocation.
If the content preview is missing, the inner format may have no dedicated view. XML that is not FatturaPA, an archive or a drawing can still be downloaded as extracted content, with a license, and opened in the right program. The name before .p7m is only a hint.
A test in five checks
- The file you selected is the one named in the message, not the PEC receipt.
- The size matches the original attachment.
- The first characters are an envelope, an expected PEM block or standard Base64, not
%PDFand not a url-safe alphabet. - You are not trying to open a PAdES file. A PDF signed internally is not a
.p7m. The difference is in CAdES and PAdES. - If the envelope opens, you have read the result and not replaced it with the mere fact that the pages are visible.
A concrete case to take apart
The message says “I attach the signed contract”. Downloads show contratto.pdf.p7m at 20 KB and, in the same PEC, smime.p7s of a few KB and daticert.xml. A twenty-kilobyte contract is suspicious if you expected thirty pages, but it may be a short PDF. Select it in the reader. If it opens, the problem was not the file. It was Preview.
If instead the reader says it does not look like a P7M, look at the first characters. %PDF means someone already extracted or renamed it. A line -----BEGIN PKCS7----- is an expected PEM block and should open. A sequence with - and _ in place of + and / is url-safe Base64. The reader rejects it even if the name ends in .p7m. In that case do not change only the extension. Ask for the binary envelope or convert locally to the standard alphabet, without publishing the file on an unknown converter.
If the size is half of what webmail states, stop. Another attempt at “repair” does not rebuild the missing bytes. Download again or ask for a new sending. Note which message you saw. “Does not look like a P7M”, “damaged or incomplete”, “encrypted” and “nested signatures” are not synonyms and they are not cured in the same way.
Frequently asked questions
If the reader says the file does not look like a P7M, is it damaged?
Not always. It may be a renamed PDF, non-standard Base64 or the wrong PEC attachment. A truncated file, by contrast, must be requested again from the sender.
Is url-safe Base64 accepted?
No. The binary format, PEM labelled PKCS7, CMS or SIGNED DATA, and standard Base64 with correct padding are accepted. The minus sign and the underscore are not part of that alphabet.
Does an invalid signature stop you reading the document?
No, when the envelope opens. Unconfirmed integrity, an expired certificate or unavailable revocation leave the content readable. Those results should be read, not silently discarded.
How many nested envelopes can be opened?
The expected layers are shown separately. Beyond the allowed maximum the file does not open, and the message refers to too many nested signatures.
When to ask for a new sending
Ask for a new copy if the size does not match, if the sender confirms that the original file is different, or if your binary copy also produces an incomplete-file error. Do not ask for a new sending only because Preview does not know .p7m. In that case select the file in the reader and continue with the signature checks.