I am having some issues communicating to certain third party system, through CURL in PHP.

This is part of the code I have to submit come requests

```
$query = '<tag>some xml content with request data</tag>';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://secure.certainsystem.com/function.php");

curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_POST, 1);

$data = curl_exec($ch);

```

The request is the same for all cases, **but sometimes** I don't get any data from the `curl_exec($ch)`, and instead, when I run `curl_error($ch)`, I get:

> 
> SSL peer certificate or SSH remote key was not OK
> 
> 
> 

This is not happening all the times, but it is happening, so I'm not sure what the problem could be, if the problem is in the code, or there is a problem in the third party system I'm comunicating to.

I searched for this message error in other places and here as well, and I found that if `CURLOPT_SSL_VERIFYPEER` is set to `true`, then it could be a problem with the third party system's certificate, perhaps a self-signed one. But in my case, that option is set to `0`, which I assume is taken as `false`.

Recently I found there is an option `CURLOPT_SSL_VERIFYHOST`, but I'm not setting that option to any value, so I think it is taking the default, which according to PHP.net documentation, is `2`, which means:

> 
> 2 to check the existence of a common name and also verify that it matches the hostname provided.
> 
> 
> 

Thank you very much for your help.