PHP about PKCS7 signature verification. Workaround

Source: Internet
Author: User
PHP about PKCS7 signature verification.
The message you want to sign so, recipient can be sure it is you
Sent it
$data = << <>

You had my authorization to spend in 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" and "=" [email protected] ",//keyed syntax
"From:hq <[email protected]>",//indexed syntax
"Subject" = "Eyes only")
)) {
Message signed-send It!
EXEC (Ini_get ("Sendmail_path"). "< Signed.txt");
}
?>
Using this function to do the signature, involving the file read and write, may involve the high concurrency of the file, what is the best way to handle PHP?
The point is, I just need to pass the original data need to be signed $data, and this function every time the original data $data saved to the file, and then do the signature, and finally the string generated after the signature saved to Signed.txt, in practice this will certainly trigger the file operation problem, how to solve it?

------Solution--------------------
Do not use the same file name, you can use MD5 (UNIQID). ". TXT "as the file name for Msg.txt and Signed.txt.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.