robrichards/xmlseclibs

Error with $algo = OPENSSL_ALGO_SHA1

Closed this issue · 4 comments

Is there any problem with OPENSSL_ALGO_SHA1 while using OpenSSL 1.1.0f (Debian 9 Stretch, PHP 7.0.19-1)?

I get exception with result : Failure Signing Data: - SHA256

Problem causes this block of code:

459:         * @return string
460:         * @throws Exception
461:         */
462:        private function signOpenSSL($data)
463:        {
464:            $algo = OPENSSL_ALGO_SHA1;
465:            if (! empty($this->cryptParams['digest'])) {
466:                $algo = $this->cryptParams['digest'];
467:            }
468:            if (! openssl_sign($data, $signature, $this->key, $algo)) {
469:                throw new Exception('Failure Signing Data: ' . openssl_error_string() . ' - ' . $algo);
470:            }
471:            return $signature;
472:        }
473:    

Thanks.

It seems $algo is being overwritten in line 466 with the value of SHA256 whereas openssl_sign expects a value of OPENSSL_ALGO_SHA256

Thanks for your reply.
Is there any way to change this behavior? From what place it takes 'digest'?
I set message digest in openssl.cnf force to sha1, but without any effect.

Problem solved.
This has been caused by missing SSL certificate for another component which used this library :)

Sorry and thanks for your time.

No worries