error certificate verify failed on pvm.json
Closed this issue · 1 comments
Here the error :
[2023-07-03 19:12:39] glpiphplog.WARNING: *** PHP Warning (2): file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:0A000086:SSL routines::certificate verify failed in /var/www/glpi/plugins/jamf/inc/cron.class.php at line 76
Backtrace :
plugins/jamf/inc/cron.class.php:76 file_get_contents()
src/CronTask.php:1018 PluginJamfCron::cronUpdatePMV()
front/crontask.form.php:52 CronTask::launch()
public/index.php:73 require()
[2023-07-03 19:12:39] glpiphplog.WARNING: *** PHP Warning (2): file_get_contents(): Failed to enable crypto in /var/www/glpi/plugins/jamf/inc/cron.class.php at line 76
Backtrace :
plugins/jamf/inc/cron.class.php:76 file_get_contents()
src/CronTask.php:1018 PluginJamfCron::cronUpdatePMV()
front/crontask.form.php:52 CronTask::launch()
public/index.php:73 require()
System Specifications (please complete the following information):
- GLPI Server OS: Ubuntu 22.04.2 LTS
- Browser Chrome
- Plugin version 3.0.2
- GLPI 10.0.7
I have found a solution but not really nice
Here the fixe ( adding contextoptions )
inc/cron.class.php
public static function cronUpdatePMV(CronTask $task): int
{
$arrContextOptions =[
'ssl' => [
'verify_peer'=> false,
'verify_peer_name'=> false,
],
];
$url = 'https://gdmf.apple.com/v2/pmv';
$out_file = GLPI_PLUGIN_DOC_DIR . '/jamf/pmv.json';
$json = file_get_contents($url, false, stream_context_create($arrContextOptions));
if ($json === false) {
$task->log(__('Unable to fetch PMV JSON from Apple', 'jamf'));
return 0;
}
https://stackoverflow.com/a/39807251/5870394
You can find a link in the comments of this answer to a root certificate bundle meant to be used with Curl which will also work for OpenSSL.