PHP OpenSSL undefined constant OPENSSL_ALGO_DSS1

1.2k views Asked by At

I am running PHP 5.2.13 on a Windows Server 2008 R2 machine (Windows 7 equivalent).

I'm mostly writing this just because I get a google dead end on searching for the warning and I'm trying to add something for it.

I am getting the following notice / warning:

Use of undefined constant OPENSSL_ALGO_DSS1 - assumed 'OPENSSL_ALGO_DSS1'

openssl_verify() expects parameter 4 to be long, string given

When running this line of code:

return openssl_verify($data, $signature, $this->getPublicKey(), OPENSSL_ALGO_DSS1);

Obviously the second warning is caused by the first.

However the problem isn't that the OpenSSL library isn't loaded, as I have the following output from phpinfo:

OpenSSL support     enabled
OpenSSL Version     OpenSSL 0.9.8k 25 Mar 2009 

This is working on all other machines that it has been tested on, so there is something machine specific.

The only difference I have spotted is the following from phpinfo:

Registered Stream Socket Transports     tcp, udp

vs on machines where it is working:

Registered Stream Socket Transports     tcp, udp, ssl, sslv3, sslv2, tls

But I'm not sure if that's a red herring or not.

1

There are 1 answers

2
icc97 On BEST ANSWER

My solution for the problem was to uninstall PHP completely and run the php-5.2.13-nts-x86.msi installer and install the OpenSSL library through there.

I had done a manual installation of the OpenSSL library rather than using the Windows installer.

I now do have the following in phpinfo:

Registered PHP Streams  php, file, data, http, ftp, compress.zlib, https, ftps
Registered Stream Socket Transports     tcp, udp, ssl, sslv3, sslv2, tls 

As far as I can tell even according to the openssl installation documentation there shouldn't be a requirement to have to install using the installer. On other machines I haven't had this problem. Altering the 'Registered Stream Socket Transports' to include ssl should only require installing the open_ssl library and adding a line to the php.ini file e.g. this answer.