Repository navigation
Verify TLS certificates and hostnames by default - #587
Merged
Merged
Conversation
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #575
Problem
CurlDispatcherfell back toCURLOPT_SSL_VERIFYPEER => falseandCURLOPT_SSL_VERIFYHOST => 0whenssl_verify_peer/ssl_verify_hostwere not set, so every HTTPS request accepted any certificate by default.Fix
ssl_verify_peertrue andssl_verify_host2.0,false,'0'and''still disable each check, with the same normalisation as before (no PHP notice for1/trueon VERIFYHOST).nullvalue now means "use the default" (verification on) instead of disabling. This is the only behaviour change for code that sets the options.CURLOPT_RESOLVE) only mapshost:portto the checked IP; the URL keeps the original hostname, so curl still sends SNI and checks the certificate against it. Confirmed live below, including an IDN host.Before / after (live,
CurlClientwith no settings, PHP 8.5, macOS)self-signed certificate (18)certificate has expired (10)no alternative certificate subject name matches target hostnameWith
['ssl_verify_peer' => false, 'ssl_verify_host' => 0]all of the above return 200, as before.Tests
testSslVerificationIsOnByDefaultintests/CurlClientTest.php: against the existing localopenssl s_serverwith a self-signed certificate (no external network), no settings,nullsettings andssl_verify_host => 0alone are rejected with error 60; explicit disable returns 200.nullmoved out of the "disabled" list intestSslVerifyPeerFalsyValuesAreTheOnlyOnesDisabled.Not confirmed / out of scope
https://münchen.de/(UTF-8 host in the URL) returns HTTP 400 both before and after and with verification disabled, so TLS succeeds; the 400 looks like a separate Host header issue, not touched here.CURLOPT_RESOLVEagainst a trusted certificate is covered by the live checks only; the suite has no trusted local CA.CHANGELOG: 4.5.4 (Security), with how to disable verification. README settings updated.