Can't use PHPMailer to sign with S/MIME, getting "Signing Error: "

Can't use PHPMailer to sign with S/MIME, getting "Signing Error: "

我正在使用 phpmailer 尝试发送已签名的电子邮件 (S/MIME)。

我用过这个 excellent tutorial by John Dalesandro 创建自签名 S/MIME 证书并将其打包为 PKCS12 格式。

然后我按照 PHPMailer S/MIME signing 中的说明进行操作 从我的 PKCS12 包中制作 cert.crt、cert.key 和 certchain.pem

当我使用下面的代码签名时,出现“签名错误:”:

$mail->sign(
  '/mypath/cert.crt', 
  '/mypath/cert.key', 
  'mypassword',
  '/mypath/certchain.pem'
);

当我不尝试签署电子邮件时,电子邮件正常发送。

由于我的错误代码中没有任何解释,我不明白我做错了什么。

所以我从外部证书颁发机构获得了 PKCS12 中的 S/MIME 证书。然后,我如上所述制作了 cert.crt、cert.key & certchain.pem,现在可以使用了。