PHP and OpenSSL stopped working after service change - php

Recently I asked my hosting company to setup a new package and since then my existing package is now giving me errors with anything to do with using openSSL.
For instance, I have a function to generate a GUID:
function generateGUIDV4($data)
{
assert(strlen($data) == 16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
$newID = generateGUIDV4(openssl_random_pseudo_bytes(16));
This now throws an error: Fatal error: Call to undefined function openssl_random_pseudo_bytes(). From what I've researched this has to do with Fatal error: Call to undefined function openssl_random_pseudo_bytes().
Now I'm also getting an error now when I call any web services from my application which again point to the openSSL.
Error:
Objectfaultcode: "WSDL"faultstring: "SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://*******'"__proto__: Object
.I've hidden the web service as it's not public. From what I've researched this points to OpenSSL again: SOAP-ERROR: Parsing WSDL: Couldn't load from <URL>.
PHP Ini is showing openSSL IS installed
OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8b 04 May 2006
Anyone have any ideas or point me in the right direction? I've got the hosting company looking into this.

I've fixed this and it had nothing to do with the hosting company.
I published a new version of the site, but in the publish profile I told it to delete all files which deleted the .htaccess file which contained the version of PHP in.
Unfortunately, I needed version 5.4 or above to run my code but since the file was removed it dropped down to 5.2 of PHP.
So I've uploaded a new .htaccess file with the correct version in and everything is working.
Hopefully this may help someone if they're as daft as I am.

Related

PHP Version 7.3.17 on Amazon EC2 missing sodium?

When making call to sodium_crypto_pwhash_str I get the following in my Apache error log file.
PHP Fatal error: Uncaught Error: Call to undefined function
sodium_crypto_pwhash_str()
My php version, as noted is 7.3.17 running on an Amazon EC2 instance.
My php-info() does not return any relevant libsodium information other than module author info:
Sodium Frank Denis
Given the above author information references a module author am I supposed to enable the sodium module? If the answer is yes is it referenced in the php.ini file? Such as:
extension=sodium
or perhaps:
extension=libsodium
What am I missing here?
Am I not supposed to use the documented function sodium_crypto_pwhash_str?
Am I supposed to use some other method of accessing the desired functionality?
Yes normally it's included in PHP 7.2+ but when you use the AWS EC2 instances this is a bit minimalistic and not everything is included.
https://www.php.net/manual/de/sodium.installation.php
Here you can see that you have to enable it during the compiling with --with-sodium[=DIR]. So you can compile it on your own or you try another distro to get it from your package manager or you use another lib to make it work.
https://forums.aws.amazon.com/thread.jspa?threadID=293187

SOAP-ERROR: Parsing WSDL: Couldn't load from (PHP 5.6 Certificate checking)

I have been fighting the following error for longer than I would like to admit. The solutions I was finding were not related to what the actual problem was.
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://x.x.x.x/iControl/iControlPortal.cgi?WSDL=LocalLB.Class' : failed to load external entity "https://x.x.x.x/iControl/iControlPortal.cgi?WSDL=LocalLB.Class"
My prod environment is CentOS 6 which is packaged with PHP 5.3 which has been EOL since August 2014. From my understanding CentOS backports security fixes, I still wanted to do some testing with a newer version and there was some other features not available in 5.3 that I could possibly leverage.
I built out a new DEV environment with PHP 5.6 and all seemed to be working until I tried a SOAP call and got the message above. After a lot of searching I finally found that in PHP 5.6 SSL Certificate check is enabled by default. In my DEV environment it is completely contained and the application requires SSL. I do not have a valid certificate. I have not tested in my PROD environment which does have valid certificates.
To get around this I added:
'stream_context'=>stream_context_create
(
array
(
'ssl'=>array
(
'verify_peer'=>false,
'verify_peer_name'=>false
)
)
)
Here it is put together in the code. This is kind of messy just threw it together for testing.
<?php
$device_ip = "x.x.x.x";
$user = "username";
$pw = "password";
$location = "https://" . $device_ip . "/iControl/iControlPortal.cgi?";
$wsdl_class = "https://" . $device_ip . "/iControl/iControlPortal.cgi?WSDL=LocalLB.Class";
$soap_class = new SoapClient($wsdl_class, array('location'=>$location, 'login'=>$user, 'password'=>$pw, 'stream_context'=>stream_context_create(array('ssl'=>array('verify_peer'=>false, 'verify_peer_name'=>false)))));
$response = $soap_class->get_string_class(array("SomeName"));
var_dump($response);
?>
although I was able to find a workaround for not having a valid certificate. Is there a way to import the self-signed certificate so that I would not have use the workaround in my DEV environment?

PC/SC with PHP5 in windows with wampServer

I'm trying to read public data from smartCard with wampServer, PHP 5.4, winSCard and php_pcsc.dll for PHP5 (http://pecl.php.net/package/pcsc/0.2/windows).
I found this project http://hanez.org/pcsc-for-php.html (code is for php4 but my dll is for php5) and tried to do in localhost but php throws me this error "Call to undefined function SCardListReaders()".
When I see de phpinfo I can see the extension enabled but it hasn't any information (I can't put images because I haven't points), only has table headers
PC/SC
| PC/SC support | enabled |
Thank you
You may be getting an error because the function is actually scard_list_readers() not SCardListReaders() as the error shows in your post.
But before you can use most of the functions, you need to establish a context first.
Try:
$context = scard_establish_context();
$readers = scard_list_readers($context);
print_r($readers);
// then when you have your card reader's identity from $readers
$connection = scard_connect($context, 'YOUR CARD READER HERE');
$response = scard_transmit($connection, 'pdu string');

Amazon S3 - deleteObjects() - "guzzle" errors?

Here's the reduced but accurate code I'm working with.
$client = S3Client::factory(array('key'=>$ak,'secret'=>$sk));
foreach(range(1,10) as $i) $temp[] = array('Key'=>$i);
$result = $client->deleteObjects(array('Bucket'=>'bucket','Objects'=>$temp));
return $result;
Everything works, it deletes the objects as requested but it throws all of these errors from the phar file. Running this locally as you can see below.
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete=' in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285
Guzzle\Http\Exception\CurlException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Guzzle/Http/Curl/CurlMulti.php on line 365
Aws\Common\Exception\TransferException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285
I was also having this problem running WampServer on Windows 7 x64. Through dumb luck, I just stumbled across the solution.
Simply add 'scheme' => 'http' to the factory config settings and it starts working!
Little late I realize, but searches for this returned very little, hopefully this might help someone else.
I was also getting this error only when trying to deleteObjects, WAMPSERVER (64 BITS & PHP 5.4) 2.4, Windows 7 x64. I think something is wrong with the Curl extension in this version of WAMP. I installed WAMPSERVER (32BITS & PHP 5.4) 2.4 and had no issues with deleteObjects.
Possible solution is to add
'curl.options' => array('CURLOPT_HTTP_VERSION'=>'CURL_HTTP_VERSION_1_0')
to S3Client::factory options.
No more mentioned curl errors, but now I sometimes receive Simple XML error: "Entity: line 2: parser error : Extra content at the end of the document".

Error in PHP Mail_Queue PEAR library

I'm getting the following error when trying to use the PHP Mail_Queue PEAR library:
Declaration of Mail_Queue::isError() should be compatible with that of PEAR::isError()
PHP 5.2.3, Mail Queue Version 1.2.3
Searching on Google hasn't turned up anything. Any ideas what's causing this?
Surely too late but I resolved this issue by modifying the Mail/Queue.php file
The declaration of Mail_Queue::isError should match exactly the one provided in PEAR::isError which takes two arguments.
So, changing (line 584 for release 1.2.6) :
function isError($value)
To :
function isError($value, $dummy = "")
Solves the warning.
It is not 100% satisfying because this modification will disappear while next update but it saved my day (0% error & warning)

Categories