[PHP-WEBMASTER] [web-news] master: Allow for posting with self-signed certificates

Author: Derick Rethans (derickr)
Date: 2026-03-27T11:45:14Z

Commit: Allow for posting with self-signed certificates · php/web-news@5d8bd51 · GitHub
Raw diff: https://github.com/php/web-news/commit/5d8bd51b1dc74bfe88fa0485f898e2c3a68bff40.diff

Allow for posting with self-signed certificates

Changed paths:
  M lib/common.php

Diff:

diff --git a/lib/common.php b/lib/common.php
index 8c680fc..750393d 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -92,8 +92,12 @@ function posttohost($url, $data)
         'header' => 'Content-type: application/x-www-form-urlencoded',
         'content' => $data,
     ];
+ $sslOpts = [
+ 'allow_self_signed' => true, // this connects internally
+ 'verify_peer_name' => false, // our self-signed cert is for 'php.net'
+ ];

- $ctx = stream_context_create(['http' => $opts]);
+ $ctx = stream_context_create(['http' => $opts, 'ssl' => $sslOpts]);

     return file_get_contents($url, false, $ctx);
}