403 when downloading a file via PHP but not from browser

I have a 403 error when downloading a JSON file via PHP from a URL. I can open the file from the browser without problems (no errors in the dev tools).

This is the script (minus the actual URL), which I have verified as working with other sites:

$ch = curl_init($url);
$dir = '../sources/';
$file_name = basename($url);
$save_file_loc = $dir . $file_name;
$fp = fopen($save_file_loc, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CAINFO, 'C:/Program Files/php/cacert.pem');
curl_exec($ch);
echo curl_errno($ch)."n";
print_r(curl_getinfo($ch));
curl_close($ch);
fclose($fp);

The certificate comes from https://curl.se/docs/caextract.html. This is the info I get:

    [url] => the/url/path/to/json/file
    [content_type] => text/html
    [http_code] => 403
    [header_size] => 183
    [request_size] => 83
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.516273
    [namelookup_time] => 0.065622
    [connect_time] => 0.091481
    [pretransfer_time] => 0.483309
    [size_upload] => 0
    [size_download] => 418
    [speed_download] => 809
    [speed_upload] => 0
    [download_content_length] => 418
    [upload_content_length] => 0
    [starttransfer_time] => 0.516216
    [redirect_time] => 0
    [redirect_url] =>
    [primary_ip] => (the.url.primary.ip.address)
    [certinfo] => Array
        (
        )

    [primary_port] => 443
    [local_ip] => (my.local.ip)
    [local_port] => 65046
    [http_version] => 3
    [protocol] => 2
    [ssl_verifyresult] => 0
    [scheme] => HTTPS
    [appconnect_time_us] => 483121
    [connect_time_us] => 91481
    [namelookup_time_us] => 65622
    [pretransfer_time_us] => 483309
    [redirect_time_us] => 0
    [starttransfer_time_us] => 516216
    [total_time_us] => 516273
    [effective_method] => GET

Of course I tried setting a user agent as well, but no chance.

What am I missing?