openssl_cms_sign
(PHP 8)
Sign a file
Description
This function signs a file with an X.509 certificate and key.
Parameters
input_filenameThe name of the file to be signed.
output_filenameThe name of the file to deposit the results.
certificateThe signing certificate. See Key/Certificate parameters for a list of valid values.
private_keyThe key associated with
certificate. See Key/Certificate parameters for a list of valid values.headersAn array of headers to be included in S/MIME output.
flagsFlags to be passed to
cms_sign().encodingThe encoding of the output file. One of
OPENSSL_ENCODING_SMIME,OPENSSL_ENCODING_DERorOPENSSL_ENCODING_PEM.untrusted_certificates_filenameIntermediate certificates to be included in the signature.
Return Values
Success
Examples
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');
?>