【问题标题】:Php and email digital signature problemsphp和email数字签名问题
【发布时间】:2011-09-08 11:38:56
【问题描述】:

我尝试使用 php 对我的电子邮件进行数字签名,但我遇到了一些问题。 我已经生成了用我自己的 CA 和 open ssl 签名的证书:

openssl req -new -nodes -out request.pem -keyout key.pem -days 1098 -config ./openssl.cnf
openssl ca -in request.pem -out cert.pem -config ./openssl.cnf

我已生成私钥 key.pem 签名证书 04.pem 在 apache 的 doc root 中,我有文件 podepsany_email.php 和 cert + key 旁边。

对于数字签名,我使用函数 openssl_pkcs7_sign()。 代码:

openssl_pkcs7_sign("./msg.txt", "./signed.txt", "./04.pem" ,"./key.pem", $headers);

调用我的脚本的结果是错误信息:

警告:openssl_pkcs7_sign() [function.openssl-pkcs7-sign]:错误 在第 70 行获取 C:\data\www\podepsany_email.php 中的私钥

请有人告诉我如何解决这个问题?谢谢

K.

【问题讨论】:

  • 文件上没有设置任何密码或密码?
  • 不,密钥是在没有密码的情况下导出的。解决此问题的方法是将函数调用中的所有文件路径更改为绝对路径。然后函数运行没有问题。
  • 您可以将其放入答案中,然后通过勾选关闭问题自行接受。

标签: php email openssl digital-signature


【解决方案1】:

查看 php 文档讨论:http://php.net/manual/en/function.openssl-pkcs7-sign.php

您应该在 .pem 文件名前加上“file://”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 1970-01-01
    • 2015-05-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多