Related Links : Search Engine Optimization | | Search Engine Marketing | Online Marketing | Freelance Programmer| SEO Thailand | SEO Expert | SEO services | PHP Programmer Thailand | SEO Tutorial | What is SEO |

  Home Our SEO Services SEO Expert Consultant Php Programmer Scripts| Email : sachin {at} jainsachin {dot} com

PHP | Sign an S/MIME message | Manual | Tutorial | Help

SEO Services



Website Programming in PHP / MYSQL



Friends


    Sign an S/MIME message

    openssl_pkcs7_sign

    (PHP 4 >= 4.0.6, PHP 5)

    openssl_pkcs7_sign — Sign an S/MIME message

    Description

    bool openssl_pkcs7_sign ( string $infilename , string $outfilename , mixed $signcert , mixed $privkey , array $headers [, int $flags [, string $extracerts ]] )

    openssl_pkcs7_sign() takes the contents of the file named infilename and signs them using the certificate and its matching private key specified by signcert and privkey parameters.

    Parameters

    infilename

    outfilename

    signcert

    privkey

    headers

    headers is an array of headers that will be prepended to the data after it has been signed (see openssl_pkcs7_encrypt() for more information about the format of this parameter.

    flags

    flags can be used to alter the output - see PKCS7 constants - if not specified, it defaults to PKCS7_DETACHED.

    extracerts

    extracerts 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.

    Return Values

    Returns TRUE on success or FALSE on failure.

    Examples

    Example #1 openssl_pkcs7_sign() example

    <?php
    // the message you want to sign so that recipient can be sure it was you that
    // sent it
    $data = <<<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(
    "file://mycert.pem""mypassphrase"),
        array(
    "To" => "joes@example.com"// keyed syntax
              
    "From: HQ <ceo@example.com>"// indexed syntax
              
    "Subject" => "Eyes only")
        )) {
        
    // message signed - send it!
        
    exec(ini_get("sendmail_path") . " < signed.txt");
    }
    ?>


    SEO Tutorial / Articles





    Php / Mysql Tutorial



    Articles



      Portfolio


      SEO by Jainsachin