array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.openssl-cms-sign.php', 1 => 'openssl_cms_sign', ), 'up' => array ( 0 => 'ref.openssl.php', 1 => 'OpenSSL Funções', ), 'prev' => array ( 0 => 'function.openssl-cms-read.php', 1 => 'openssl_cms_read', ), 'next' => array ( 0 => 'function.openssl-cms-verify.php', 1 => 'openssl_cms_verify', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/openssl/functions/openssl-cms-sign.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 8)
openssl_cms_sign — Sign a file
$input_filename
,$output_filename
,$certificate
,$private_key
,$headers
,$flags
= 0,$encoding
= OPENSSL_ENCODING_SMIME
,$untrusted_certificates_filename
= null
This function signs a file with an X.509 certificate and key.
input_filename
The name of the file to be signed.
output_filename
The name of the file to deposit the results.
certificate
The signing certificate. See Key/Certificate parameters for a list of valid values.
private_key
The key associated with certificate
.
See Key/Certificate parameters for a list of valid values.
headers
An array of headers to be included in S/MIME output.
flags
Flags to be passed to cms_sign().
encoding
The encoding of the output file. One of OPENSSL_ENCODING_SMIME
,
OPENSSL_ENCODING_DER
or OPENSSL_ENCODING_PEM
.
untrusted_certificates_filename
Intermediate certificates to be included in the signature.
Exemplo #1 openssl_cms_sign() example
<?php
openssl_cms_sign('input.txt', 'output.txt', 'file://cert.pem', 'file://privkey.pem', null, OPENSSL_CMS_BINARY, OPENSSL_ENCODING_DER, 'chain.pem');
?>