Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:63620 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88111 invoked from network); 25 Oct 2012 10:38:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Oct 2012 10:38:38 -0000 Authentication-Results: pb1.pair.com header.from=sebastian.krebs.berlin@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.170 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.215.170 mail-ea0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:48427] helo=mail-ea0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E6/94-59506-CA619805 for ; Thu, 25 Oct 2012 06:38:37 -0400 Received: by mail-ea0-f170.google.com with SMTP id a13so516377eaa.29 for ; Thu, 25 Oct 2012 03:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:x-google-sender-delegation:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type; bh=YKTMfkwWVjCaZOYPs7BAtKx4iUE+06ZhINdCMai6l88=; b=Gp9VVPocXWjKSvG/nE4PLajzzlBvo9mFHqr2YQzPbN2oKVu40U0/tlzwSJTOiIWky5 w7J9JegA3MNumxM/z/gArC7MunauSFn1fOq0+/1J9eVLDFlPIrp35Mu6Rm4yoGdVf98M KlbShjuQt0texUxJ4iAF2OKIvX4N1lsuYo7a4Nktq/MVyKq0TuQuytZBLNusB58I891S hPRVdUiBon533yaeRA/MrtaEGvD0QwTBOr/8YnTP5rD5lENfiXzncpd362bQVL0jI7wG 6VEN6TtkO17RnvsAM4LFUP50TGOXgZxEiDe8YzNfQO+nBxVYcc68B8pv/Q9bC+PX+iEH HIsQ== MIME-Version: 1.0 Received: by 10.14.0.198 with SMTP id 46mr25923379eeb.21.1351161514453; Thu, 25 Oct 2012 03:38:34 -0700 (PDT) Sender: sebastian.krebs.berlin@gmail.com X-Google-Sender-Delegation: sebastian.krebs.berlin@gmail.com Received: by 10.14.207.67 with HTTP; Thu, 25 Oct 2012 03:38:34 -0700 (PDT) In-Reply-To: References: Date: Thu, 25 Oct 2012 12:38:34 +0200 X-Google-Sender-Auth: kopmPa8m1g960ntZIrSSmg-cSWI Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=047d7b62275e1a690a04ccdfcec1 Subject: Re: [PHP-DEV] Changing the default value of "true" for CURLOPT_SSL_VERIFYHOST From: krebs.seb@gmail.com (Sebastian Krebs) --047d7b62275e1a690a04ccdfcec1 Content-Type: text/plain; charset=ISO-8859-1 2012/10/25 crankypuss > On 10/24/2012 11:34 PM, Sherif Ramadan wrote: > >> On Thu, Oct 25, 2012 at 1:03 AM, JJ wrote: >> >>> Hey all - I'd like start a discussion around pull request 221 >>> (https://github.com/php/php-**src/pull/221 >>> ). >>> >>> In short, there's a high volume of [incorrect] code out there which >>> looks like: >>> >>> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); >>> >>> Instead of what, in all likelyhood, the code meant to do: >>> >>> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); >>> >>> This is due to the convert_to_long_ex call which converts "true" to >>> 1L. CURLOPT_SSL_VERIFYHOST being set to 1L bypasses common name >>> validation within libcurl. >>> >>> My solution was to check the type for CURLOPT_SSL_VERIFYHOST: if it is >>> boolean and true, the opt value for libcurl is set to 2L. >>> >>> I understand that engineers should have the proper option value to >>> begin with but weighing the impact of this (MITM attacks) against >>> doing what they probably meant anyways is worth the presumption. >>> >>> Please discuss and adjust the patch if necessary. >>> >>> - JJ >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> While I think it's a good idea to set the value of the option to 2, as >> is recommended for production in the documentation, I think the idea >> of implicitly converting a bool(true) to 2L internally might lead to >> unexpected behavior since some people might actually depend on normal >> PHP behavior to cast a bool(true) to 1 (and that might be what they >> actually intended). >> >> I understand there are people out there that don't read the >> documentation and aren't aware of the difference between >> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); and curl_setopt($ch, >> CURLOPT_SSL_VERIFYHOST, true); but still... I don't think this is a >> good idea either. >> >> We should probably just elaborate on this point a bit more in the >> documentation. Perhaps add a note and an example to illustrate. I >> notice that people tend to pay more attention to examples than >> anything else in the docs. >> >> > Booleans ought to be 1 and 0. Casting a boolean to 2 is just wrong, a way > to fix badly written code a few people have written and in so doing risk > the breakage of far more code that is correct. Thats not completely true. Boolean 'false' is equal to 0 and Boolean 'true' is something different than 0, that _may_ be 1 (and in most cases is), but it's not limited too. Just said. > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- github.com/KingCrunch --047d7b62275e1a690a04ccdfcec1--