Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lewiscainscube's avatar

OpenSSL 'Failed to enable crypto' error on Ubuntu Digital Ocean Droplet

Hi all,

I am using Guzzle to connect with the Zoopla Property Group Api as follows:

    $client = new \GuzzleHttp\Client([ 'exceptions' => false ]);
        $request = $client->post('https://realtime-listings-api.webservices.zpg.co.uk/sandbox/v1/listing/list', array(
            'ssl_key'   => 'path/to/my/private.pem',
            'cert'      => 'path/to/my/zpg.crt',
            'json'      => ['branch_reference' => '123456'],
            'headers'   => [
                'content-type' => 'application/json;profile=http://realtime-listings.webservices.zpg.co.uk/docs/v1.1/schemas/listing/list.json',
            ]
        ));

Locally I am using Laravel Homestead and have been able to connect and work fine.

However, I am now wanting to test live and so I have deployed this to a new Digital Ocean Ubuntu (version 16.04 x64) droplet and when I try and make the same call as above I get the following output:

    Error creating resource: [message] fopen(): Unable to set private key      file `/var/www/mydomain.co.uk/path/to/my/zpg.crt'
    [file]     /var/www/mydomain.co.uk/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
    [line] 287
    [message] fopen(): Failed to enable crypto
    [file]    /var/www/mydomain.co.uk/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php
    [line] 287 [message] fopen(https://realtime-listings-api.webservices.zpg.co.uk/sandbox/v1/listing/list): 
    failed to open stream: operation failed
    [file] /var/www/mydomain.co.uk/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php

I believe that the answer may lie in the

    fopen(): Failed to enable crypto

line but I'm struggling to find anything which may help. All file paths are correct, and the file permissions are set the same as locally where it is working. Is this just a simple case of needing to enable a setting or install something extra on my droplet? Any help would be greatly appreciated.

Many thanks, Lewis

0 likes
6 replies
lewiscainscube's avatar

Hi again folks, has anyone got any thoughts on this one? Still stuck :-)

lewiscainscube's avatar

@yajra Hi, yes my solution was to just go with one of the ready made Digital Ocean boxes (one click apps) rather than try and be too clever and configure it myself. I went to https://cloud.digitalocean.com/droplets/new?size=2gb and selected the 'Lamp on 14.04' box and everything worked fine. I installed that and somewhere within that setup was the required configuration. I still don't know what the underlying issue was and neither did here, Stack Overflow, Slack chatrooms and other things I tried so that's frustrating but ultimately I needed it to work and this was what did it for me. Hope it helps. Thanks, Lew

yajra's avatar

@lewiscainscube thanks for the response. I guess I need to do more searching as my server is not on Digital Ocean and just a custom one. Will let you know if I can hopefully find the underlying issue. Thanks!

lewiscainscube's avatar

@yajra If anyone else comes across this, I encountered the same issue this morning when trying to upgrade my box to PHP7 but this time I've managed to fix it!!!

Basically here's my process:

sudo apt-get install -y language-pack-en-base sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php7.0 php7.0-mysql php7.0-mcrypt php7.0-gd php7.0-mbstring php7.0-dom php7.0-mhash php-curl sudo a2dismod php5 sudo a2enmod php7.0 service apache2 restart

IMPORTANT - the php-curl installation is what got rid of the error so if anyone encounters this, make sure you at least run sudo apt-get install php-curl

Hope that helps someone, Lew

yajra's avatar

@lewiscainscube thanks for the update, not sure but maybe re-installing php-curl might have done the trick to fix it (not sure cause another person fixed the server ^_^).

However, the next issue that raised was cURL error 35: Unknown SSL protocol error. Have set the ssl verifier false on guzzle but still no luck. Do you have any idea on this? Thanks!

Please or to participate in this conversation.