How to enable HTTPS stream wrappers

How to enable HTTPS stream wrappers

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

How to enable HTTPS stream wrappers

When executing a PHP script from the command line, encountering the error "Unable to find wrapper 'https'" is a common friction point, especially on Windows systems where default configurations often differ from Linux distributions. The error stems from the fact that file_get_contents() relies on the underlying stream wrapper system to fetch data, and without explicit configuration, PHP may not load the necessary modules to handle secure sockets layer (SSL) connections.

In the provided scenario, the script attempts to query the AWS EC2 API using a raw GET request via https://ec2.amazonaws.com. While the logic for constructing the signature and formatting the query string is correct according to the AWS Signature Version 2 spec, the runtime environment lacks the extension required to resolve the HTTPS protocol. On Windows, PHP often installs without the SSL module enabled by default because it requires specific cryptographic libraries that are not always bundled in the standard installer.

To settle this issue, you must ensure that the openssl extension is loaded and that the stream wrappers are explicitly enabled. The most direct solution involves editing your php.ini configuration file. You need to locate the line extension=php_openssl.dll (or similar, depending on your PHP version) and remove the semicolon at the beginning if it exists. This loads the core library needed for SSL operations.

Once the extension is loaded, you must also ensure that the stream wrappers are active. Look for lines like ;openssl.cafile, ;openssl.capath, or explicitly commented-out wrapper definitions. While modern PHP versions often enable these automatically upon loading the OpenSSL extension, legacy configurations or specific Windows builds might require manual activation. You can verify if the wrappers are available by running:

php -r "echo 'https' in get_loaded_extensions() ? 'loaded' : 'missing';"

Or more accurately for stream wrappers specifically:

php -r "var_dump(get_stream_wrappers());"

If https is missing from the list, enabling the OpenSSL extension usually resolves it. If you are using a custom PHP build or a specific installer from a vendor like WAMP/XAMPP, check the documentation for that package to ensure the SSL libraries were included during installation.

Another critical pitfall involves the path to the certificate authority (CA) bundles. On Windows, file_get_contents() with HTTPS will fail silently or throw an error if it cannot verify the server's certificate against a trusted root store. By default, PHP might not know where the CA certificates are located. You can address this by setting the openssl.cafile and openssl.capath directives in your php.ini:

openssl.cafile = "C:/path/to/ca-bundle.crt"
openssl.capath = "C:/path/to/certs"

If you do not have a custom CA bundle, ensure that the system's default certificate store is accessible to PHP. On some Windows configurations, this requires installing the Root Certificates for all known SSL issuers (the root certificates) onto the machine first. Once installed, you might need to point PHP to the directory containing these certificates or rely on the OS-level crypto provider which modern PHP versions support automatically.

Finally, consider the trade-offs between using file_get_contents() and cURL for complex API interactions. While file_get_contents() is convenient for simple requests, it offers less control over SSL verification flags (like disabling verification for testing purposes) compared to cURL. If you need to bypass certificate errors during local development without modifying the CA path, cURL provides a dedicated option (CURLOPT_SSL_VERIFYPEER) that stream wrappers do not expose as easily. However, for production environments and straightforward API calls like the EC2 example above, ensuring the OpenSSL extension is loaded and the CA bundle is correctly configured is the robust approach.

For developers working within the Laravel ecosystem or those seeking deeper integration with PHP services, understanding these underlying streams is crucial. Resources like https://laravelcompany.com often provide insights into managing server configurations where such low-level details impact application reliability.

Our network