Php about pkcs7 signature verification. & Lt ;? Phpthemessageyouwanttosignsothatrecipientcanbesureitwasyouthatsentit $ data & lt; EODYouhavemyauthorizationtospend $10,000 o php about pkcs7 signature verification.
// The message you want to sign so that recipient can be sure it was you that
// Sent it
$ Data = <
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 ", // Indexed syntax
"Subject" => "Eyes only ")
)){
// Message signed-send it!
Exec (ini_get ("sendmail_path"). "<signed.txt ");
}
?>
Using this function for signature involves reading and writing files, which may involve high concurrency of files. Is there any good solution for php?
In practice, this will certainly trigger file operations. how can this problem be solved?
------ Solution --------------------
Do not use the same file name. you can use md5 (uniqid). ". txt" as the file name of msg.txtand signed.txt.