Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 1975

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>openssl_pkcs7_sign</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="OpenSSL functions"
HREF="ref.openssl.html"><LINK
REL="PREVIOUS"
TITLE="openssl_pkcs7_encrypt"
HREF="function.openssl-pkcs7-encrypt.html"><LINK
REL="NEXT"
TITLE="openssl_pkcs7_verify"
HREF="function.openssl-pkcs7-verify.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.openssl-pkcs7-encrypt.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.openssl-pkcs7-verify.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.openssl-pkcs7-sign"
></A
>openssl_pkcs7_sign</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN68285"
></A
><P
>    (PHP 4 &#62;= 4.0.6)</P
>openssl_pkcs7_sign&nbsp;--&nbsp;sign an S/MIME message</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN68288"
></A
><H2
>Description</H2
>bool <B
CLASS="methodname"
>openssl_pkcs7_sign</B
> ( string infilename, string outfilename, mixed signcert, mixed privkey, array headers [, long flags [, string extracertsfilename]])<BR
></BR
><P
>&#13;    <B
CLASS="function"
>openssl_pkcs7_sign()</B
> takes the contents of the file
    named <TT
CLASS="parameter"
><I
>infilename</I
></TT
> and signs them using the
    certificate and it's matching private key specified by
    <TT
CLASS="parameter"
><I
>signcert</I
></TT
> and <TT
CLASS="parameter"
><I
>privkey</I
></TT
>
    parameters.
   </P
><P
><TT
CLASS="parameter"
><I
>headers</I
></TT
> is an array of headers that
    will be prepended to the data after it has been signed (see
    <A
HREF="function.openssl-pkcs7-encrypt.html"
><B
CLASS="function"
>openssl_pkcs7_encrypt()</B
></A
> for more information about
    the format of this parameter.
   </P
><P
>&#13;    <TT
CLASS="parameter"
><I
>flags</I
></TT
> can be used to alter the output - see <A
HREF="ref.openssl.html#openssl.pkcs7.flags"
>PKCS7 constants</A
> - if not specified,
    it defaults to PKCS7_DETACHED.
   </P
><P
>&#13;    <TT
CLASS="parameter"
><I
>extracerts</I
></TT
> specifies the name of a file containing
    a bunch of extra certificates to include in the signature which can for
    example be used to help the recipient to verify the certificate that you used.
   </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN68328"
></A
><P
><B
>Example 1. <B
CLASS="function"
>openssl_pkcs7_sign()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>// the message you want to sign so that recipient can be sure it was you that
// sent it
$data = &#60;&#60;&#60;EOD

You have my authorization to spend $10,000 on dinner expenses.

The CEO
EOD;
// save message to file
$fp = fopen("msg.txt", "w");
fwrite($fp, $data);
fclose($fp);
// encrypt it
if (openssl_pkcs7_sign("msg.txt", "signed.txt", "mycert.pem",
    array("mycert.pem", "mypassphrase"),
    array("To" =&#62; "joes@sales.com", // keyed syntax
          "From: HQ &#60;ceo@sales.com&#62;", // indexed syntax
          "Subject" =&#62; "Eyes only"))
{
    // message signed - send it!
    exec(ini_get("sendmail_path") . " &#60; signed.txt");
}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>This function was added in 4.0.6.</P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.openssl-pkcs7-encrypt.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.openssl-pkcs7-verify.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>openssl_pkcs7_encrypt</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.openssl.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>openssl_pkcs7_verify</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>