Skip to content

Commit 284e06b

Browse files
vjardinGirgias
authored andcommitted
Improve openssl-pkcs7-read + example for p7b
The input shall be a string data. Basic example along with the error cases.
1 parent 1200e4e commit 284e06b

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

reference/openssl/functions/openssl-pkcs7-read.xml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
&reftitle.description;
1111
<methodsynopsis>
1212
<type>bool</type><methodname>openssl_pkcs7_read</methodname>
13-
<methodparam><type>string</type><parameter>input_filename</parameter></methodparam>
13+
<methodparam><type>string</type><parameter>data</parameter></methodparam>
1414
<methodparam><type>array</type><parameter role="reference">certificates</parameter></methodparam>
1515
</methodsynopsis>
1616
<para>
@@ -25,18 +25,18 @@
2525
&reftitle.parameters;
2626
<variablelist>
2727
<varlistentry>
28-
<term><parameter>input_filename</parameter></term>
28+
<term><parameter>data</parameter></term>
2929
<listitem>
3030
<para>
31-
31+
The string of data you wish to parse (p7b format).
3232
</para>
3333
</listitem>
3434
</varlistentry>
3535
<varlistentry>
3636
<term><parameter>certificates</parameter></term>
3737
<listitem>
3838
<para>
39-
39+
The array of PEM certificates from the p7b input data.
4040
</para>
4141
</listitem>
4242
</varlistentry>
@@ -50,6 +50,46 @@
5050
</para>
5151
</refsect1>
5252

53+
<refsect1 role="examples">
54+
&reftitle.examples;
55+
<para>
56+
<example>
57+
<title>Get a PEM array from a P7B file</title>
58+
<programlisting role="php">
59+
<![CDATA[
60+
<?php
61+
62+
$file = 'certs.p7b';
63+
64+
$f = file_get_contents($file);
65+
$p7 = array();
66+
$r = openssl_pkcs7_read($f, $p7);
67+
68+
if ($r === false) {
69+
printf("ERROR: %s is not a proper p7b file".PHP_EOL, $file);
70+
for($e = openssl_error_string(), $i = 0; $e; $e = openssl_error_string(), $i++)
71+
printf("SSL l%d: %s".PHP_EOL, $i, $e);
72+
exit(1);
73+
}
74+
75+
print_r($p7);
76+
?>
77+
]]>
78+
</programlisting>
79+
</example>
80+
81+
</para>
82+
</refsect1>
83+
84+
<refsect1 role="seealso">
85+
&reftitle.seealso;
86+
<para>
87+
<simplelist>
88+
<member><function>openssl_csr_sign</function></member>
89+
</simplelist>
90+
</para>
91+
</refsect1>
92+
5393

5494
</refentry>
5595
<!-- Keep this comment at the end of the file

0 commit comments

Comments
 (0)