cconard96 / jamf

JAMF Plugin for GLPI
GNU General Public License v2.0
6 stars 5 forks source link

error certificate verify failed on pvm.json #123

Closed FlorentDerangere closed 6 months ago

FlorentDerangere commented 1 year ago

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):

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;
    }
cconard96 commented 1 year ago

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.