tiamo / phpas2

PHPAS2 is a php-based implementation of the EDIINT AS2 standard.
42 stars 41 forks source link

CryptoHelper::verify method seems wrong #31

Open mcorteel-harel opened 3 years ago

mcorteel-harel commented 3 years ago

The CryptoHelper::verify() method (here) uses openssl_pkcs7_verify. But the parameters do not match the documentation at all:

Am I missing something here?

mackieee commented 3 years ago

The first paramater supplied to openssl_pkcs7_verify is a temporary filename, on the basis that $data is checked to be an instance of MimePart at the beginning of the method

From what i can gather though for the other paramaters - these have changed since the PHP 7 upgrade:

PHP 5 Docs on openssl-pkcs7-verify: https://php-legacy-docs.zend.com/manual/php4/en/function.openssl-pkcs7-verify

The arguments linked above I think matches the input on the verify method.

mcorteel-harel commented 3 years ago

Well the parameters look backward-compatible (at least in this case), but the $cainfo (or $ca_info) parameter still requires an array of locations, not an array of certificate strings according to the doc... Maybe it works and it's just not mentioned in the doc.

About the first parameter you are right though, it's just that the this docblock is wrong, because providing a string would skip over the getTempFilename part and provide the content as-is to the openssl_pkcs7_verify function (which again might work but is not documented that way).

I'm having an issue with this method in my use case (upon reception of a signed message) and I'm looking for the source of the problem.