[doc-en] master: openssl_cms_read - docs added (#5951)
| From: | Alexander Danilov via GitHub | Date: | Wed, 28 Oct 2026 06:24:49 +0000 |
| Subject: | [doc-en] master: openssl_cms_read - docs added (#5951) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23896@lists.php.net to get a copy of this message | ||
Author: Alexander Danilov (adapik)
Committer: GitHub (web-flow)
Pusher: lacatoire
Date: 2026-10-28T07:24:46+01:00
Commit: https://github.com/php/doc-en/commit/a97993d2ccf0c9a0a4433a3db171893632be73b7
Raw diff: https://github.com/php/doc-en/commit/a97993d2ccf0c9a0a4433a3db171893632be73b7.diff
openssl_cms_read - docs added (#5951)
* openssl_cms_read - docs added
* The example emits a warning when the CMS contains a CRL, since
openssl_x509_parse()
returns false for it.
---------
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
Changed paths:
M reference/openssl/functions/openssl-cms-read.xml
Diff:
diff --git a/reference/openssl/functions/openssl-cms-read.xml
b/reference/openssl/functions/openssl-cms-read.xml
index 29866a2ecf5d..2c6f87d7ece4 100644
--- a/reference/openssl/functions/openssl-cms-read.xml
+++ b/reference/openssl/functions/openssl-cms-read.xml
@@ -14,11 +14,13 @@
<methodparam><type>string</type><parameter>input_filename</parameter></methodparam>
<methodparam><type>array</type><parameter
role="reference">certificates</parameter></methodparam>
</methodsynopsis>
- <para>
- Performs the exact analog to <function>openssl_pkcs7_read</function>.
- </para>
-
- &warn.undocumented.func;
+ <simpara>
+ Extracts the certificates and <acronym>CRL</acronym>s from a
+ <acronym>PEM</acronym>-encoded <acronym>CMS</acronym> structure
+ and returns them as <acronym>PEM</acronym> strings.
+ This is the <acronym>CMS</acronym> analog of
+ <function>openssl_pkcs7_read</function>.
+ </simpara>
</refsect1>
@@ -28,17 +30,20 @@
<varlistentry>
<term><parameter>input_filename</parameter></term>
<listitem>
- <para>
-
- </para>
+ <simpara>
+ The <acronym>PEM</acronym>-encoded <acronym>CMS</acronym> data to
parse.
+ Despite its name, this is the data itself, not a path to a file.
+ </simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>certificates</parameter></term>
<listitem>
- <para>
-
- </para>
+ <simpara>
+ Filled with an array of <acronym>PEM</acronym> strings.
+ Certificates and <acronym>CRL</acronym>s are only extracted from
+ signed data; for other content types the array is left empty.
+ </simpara>
</listitem>
</varlistentry>
</variablelist>
@@ -46,11 +51,36 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
- <para>
+ <simpara>
&return.success;
- </para>
+ </simpara>
</refsect1>
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <example>
+ <title><function>openssl_cms_read</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// PEM-encoded CMS data
+$data = file_get_contents('file.pem');
+
+if (!openssl_cms_read($data, $certificates)) {
+ exit('Not a valid PEM CMS structure: ' . openssl_error_string());
+}
+
+foreach ($certificates as $pem) {
+ $info = openssl_x509_parse($pem);
+ if ($info !== false) {
+ echo $info['name'], PHP_EOL;
+ }
+}
+?>
+]]>
+ </programlisting>
+ </example>
+ </refsect1>
</refentry>