cacti icon indicating copy to clipboard operation
cacti copied to clipboard

Bugs/Imitation when using HTTPS with Self Signed Cert in "Main + Remote" Poller

Open chtay opened this issue 9 years ago • 1 comments

If the remote cacti is using self-signed certificate for the HTTPS, the existing cacti (v1.1.27 that i tested) will not work. It will show this error: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in file:{your cacti physical location}/cacti/lib/api_device.php on line: 396

In line 396 of api_device.php: print file_get_contents(get_url_type() .'://' . $hostname . $config['url_path'] . 'remote_agent.php?action=ping&host_id=' . $host['id']);

To make it work, the file_get_contents need to include the context for self-signed SSL. Thus, need to replace it with this: $fgc_contextoption = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ) ); $fgc_context = stream_context_create($fgc_contextoption); print file_get_contents(get_url_type() .'://' . $hostname . $config['url_path'] . remote_agent.php?action=ping&host_id=' . $host['id'], FALSE, $fgc_context);

The above will allow main cacti to query remote cacti, for the device/system status.

Next is in line 41 of data_query.php: $response = file_get_contents(get_url_type() . '://' . $hostname . $config['url_path'] . '/remote_agent.php?action=runquery&host_id=' . $host_id . '&data_query_id=' . $snmp_query_id);

Same thing, include the context for self-sign for the file_get_contents: $fgc_contextoption = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ) ); $fgc_context = stream_context_create($fgc_contextoption); $response = file_get_contents(get_url_type() . '://' . $hostname . $config['url_path'] . '/remote_agent.php?action=runquery&host_id=' . $host_id . '&data_query_id=' . $snmp_query_id, FALSE, $fgc_context);

The above method will work, but I think the best is to add into the config.php file or some changeable at the Configuration section on the web instead.

EDIT: BTW, I posted it in as well: https://forums.cacti.net/viewtopic.php?f=21&t=58074

chtay avatar Oct 30 '17 00:10 chtay

Resolved. Thanks for taking the time to report!

cigamit avatar Nov 04 '17 14:11 cigamit