Composer not working on Windows, gives [Composer\Exception\NoSslException] error
When attempting to install Laravel on a Windows machine, you might encounter the [Composer\Exception\NoSslException] error immediately after running any command. This isn't just a configuration glitch; it is a fundamental security enforcement mechanism within Composer's architecture. The error message explicitly states that the OpenSSL extension is required for SSL/TLS protection but is currently unavailable. While the suggestion to set disable-tls exists, enabling that flag exposes your project and dependencies to unencrypted connections, effectively bypassing modern TLS validation. For professional environments, relying on a disabled TLS connection is a significant security liability.
The root cause usually stems from how PHP extensions are loaded on Windows versus Linux. On Unix-like systems, OpenSSL is often compiled directly into the PHP binary or easily linked via shared libraries. On Windows, however, PHP relies on dynamic loadable modules (.dll files) for extensions like php_openssl.dll. If your php.ini file does not explicitly include a line pointing to this DLL file in its extension directory, Composer cannot initialize the necessary cryptographic functions.
Verifying the OpenSSL Extension
Before attempting complex workarounds, you must confirm whether the extension is simply missing or merely disabled. Run the following command in your terminal:
php -m | findstr "openssl"
If this returns no results, the extension is not loaded. If it does appear, check if it is enabled but failing to initialize due to path issues. The solution involves editing your active php.ini configuration file. You need to ensure the following line exists and points to the correct location of the DLL:
extension=php_openssl.dll
Simply adding this line might not suffice if you have restarted Apache but not the PHP CLI (Command Line Interface). Windows often runs multiple instances of PHP, and restarting a web server like Apache does not reload the CLI process. You must restart your terminal session or any IDE terminals (like VS Code) after saving the php.ini changes to ensure the new configuration is picked up by the CLI version Composer uses.
Handling Legacy or Custom Builds
Sometimes, the OpenSSL DLL exists in the extension directory but is not referenced in the configuration. In cases where you are using a custom PHP build or an older version where OpenSSL is bundled differently, you might need to verify that the DLL file actually exists in your ext folder. If the file is missing entirely, you may need to reinstall PHP with OpenSSL support enabled during the installation process, specifically ensuring that the "OpenSSL" option is selected in the setup wizard.
The Risk of Disabling TLS
If you absolutely cannot enable the OpenSSL extensionâperhaps due to an incompatible PHP version or a corrupted installationâyou can technically bypass the error by telling Composer to skip TLS verification. This is done via the global configuration command:
composer config -g --disable-tls true
However, this should be treated as a last resort. By setting disable-tls, Composer stops validating the server certificate during HTTPS requests. While this might allow you to proceed with installing packages from repositories like Packagist in a lab environment, it leaves your system vulnerable to Man-in-the-Middle (MitM) attacks. In production environments or for serious development work, maintaining SSL/TLS integrity is non-negotiable.
For those moving forward with modern Laravel stacks on Windows, ensuring that php_openssl.dll is correctly loaded in the active CLI environment remains the most robust and secure path forward.