Browse Source

add ssl options to fopen on getCert function

CauseFX 6 years ago
parent
commit
5713bc4a31
1 changed files with 10 additions and 2 deletions
  1. 10 2
      api/functions/normal-functions.php

+ 10 - 2
api/functions/normal-functions.php

@@ -316,10 +316,18 @@ function getCert()
 			return $GLOBALS['selfSignedCert'];
 		}
 	}
+	$context = stream_context_create(
+		array(
+			'ssl'=> array(
+				'verify_peer' => true,
+				'cafile' => getCert()
+			)
+		)
+	);
 	if (!file_exists($file)) {
-		file_put_contents($file, fopen($url, 'r'));
+		file_put_contents($file, fopen($url, 'r', false, $context));
 	} elseif (file_exists($file) && time() - 2592000 > filemtime($file)) {
-		file_put_contents($file, fopen($url, 'r'));
+		file_put_contents($file, fopen($url, 'r', false, $context));
 	}
 	return $file;
 }