Remove special handling for libcurl, use environment variables instead

This commit is contained in:
ljm42
2024-03-18 14:44:51 -07:00
parent 77bd950c6d
commit ffcb5b11a1
7 changed files with 1 additions and 36 deletions
@@ -324,21 +324,4 @@ function getProxyStreamContext($url, $streamContextOptions = [], $http_proxy_ove
return null;
}
}
// use after calling curl_init();
// reads environment variables and determines whether to proxy the request
// example usage: $ch = getProxyCurlOpt($url, $ch);
function getProxyCurlOpt($url, $ch, $http_proxy_override = null, $no_proxy_override = null) {
$url_host=parse_url($url, PHP_URL_HOST);
$http_proxy = $http_proxy_override ?? getenv('http_proxy');
$no_proxy = $no_proxy_override ?? getenv('no_proxy');
$no_proxy_arr = ($no_proxy) ? explode (",", $no_proxy) : [];
// do not proxy hosts listed in the no_proxy environment variable
if ($http_proxy && ! in_array($url_host, $no_proxy_arr)) {
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
curl_setopt($ch, CURLOPT_PROXY, $http_proxy);
}
return $ch;
}
?>
@@ -12,7 +12,6 @@
?>
<?
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Helpers.php";
require_once "$docroot/webGui/include/Wrappers.php";
// add translations
@@ -67,9 +66,7 @@ if ($keyfile === false) {
}
$keyfile = @base64_encode($keyfile);
$url = 'https://keys.lime-technology.com/account/ssl/provisionwildcard';
$ch = curl_init($url);
$ch = getProxyCurlOpt($url, $ch);
$ch = curl_init("https://keys.lime-technology.com/account/ssl/provisionwildcard");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
@@ -1,7 +1,6 @@
<?php
$webguiGlobals = $GLOBALS;
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Helpers.php";
class ReplaceKey
{
@@ -33,9 +32,6 @@ class ReplaceKey
{
$ch = curl_init($url);
// setup outgoing proxy
$ch = getProxyCurlOpt($url, $ch);
// Set the request method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
// store the response in a variable instead of printing it