Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47006 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2751 invoked from network); 21 Feb 2010 00:45:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2010 00:45:16 -0000 Authentication-Results: pb1.pair.com header.from=bostjan.skufca.work@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=bostjan.skufca.work@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.223 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: bostjan.skufca.work@gmail.com X-Host-Fingerprint: 209.85.220.223 mail-fx0-f223.google.com Received: from [209.85.220.223] ([209.85.220.223:48475] helo=mail-fx0-f223.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/5A-29373-A12808B4 for ; Sat, 20 Feb 2010 19:45:14 -0500 Received: by fxm23 with SMTP id 23so1303889fxm.23 for ; Sat, 20 Feb 2010 16:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=7pv+QvG1RrQjykDyhvMW3vZdMUo0Ah/so3xt7/X2g7Y=; b=qT8LlHqgzLDknww2svWloSe5YHk2KvOX2D6CKQr/OQe1Wm/zANFCuQW5cU29s62GPq tXpFNp/8GATNtHVkW90FmQxf0wYGIxc/E7pEnRZV9X/2/XATkDN4PmNCJaDCbVxL0AcD 8AknDtTbELSD3Ont6k8X3Ymzx5QQwtnT8O+pg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=l6vnFbmnVjN3hwlasVqDmUK/AsmLVbgMe4U6+6WzVmjEhJP7O6LSeaR3IUnAUQAkM+ EBPyZpZKHg5o9UzZCTR3D062t6+ElBx+48UpAJiCSFuyMJ67C5hK39eFyP8bhLaNRhEb P/I46+hKgoqgBf5/zsYFFVMp6sXL4XdBkP57o= MIME-Version: 1.0 Sender: bostjan.skufca.work@gmail.com Received: by 10.223.60.138 with SMTP id p10mr1857209fah.32.1266713110356; Sat, 20 Feb 2010 16:45:10 -0800 (PST) In-Reply-To: References: <7b9883441002201156i462221ccked6f1c0aa0b49b56@mail.gmail.com> Date: Sun, 21 Feb 2010 01:45:10 +0100 X-Google-Sender-Auth: eed41654d7c1f4a8 Message-ID: <7b9883441002201645u70965031jb7fd3098324a00db@mail.gmail.com> To: Pierre Joye Cc: internals@lists.php.net, wez@php.net, kingwez@gmail.com, pajoye@php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Patch for ext/openssl to support CN_match with asterisk From: bostjan@a2o.si (Bostjan Skufca) The patch includes code which is very similar but it's functionality goes just the other way around. The original code takes remote CN and if that contains asterisk, it tries to 'limited-wildcard-match' of CN_match against remote CN (remote CN is the pattern in this case, if you will). On the other hand, added code checks if CN_match contains asterisk and if so, it does 'limited-wildcard-match' of REMOTE CN against CN_match pattern. The original version 'could' be enough if you are only considering PHP as a SSL client. Now, what I am trying to achieve is a whole standalone application server written in PHP. That is, whole forking/process management etc stuff. And I would like to set it up like this: - it has a SSL listening socket - set CN_match for listening socket to '*.example.org' - create listening socket with stream_socket_server All above in order to accept connections only from clients which present themselves with appropriate certificate (based on cacert check which works OK) and appropriate CN. To illustrate the desired functionality: - CNs host1.example.org and host2.example.org are OK, - but not CN host3.otherdomain.org, even if it presents a certificate from the same CA as the two above. Was I clear enough now? :) b. PS: I've just discovered another issue. In the context of creating listening socket with stream_socket_create, again. If a preceeding SSL client has introduced itself with client certificate, and the current client does not, the [ssl][peer_certificate] of the new socket's context options still contains a reference to a resource of preceeding client's certificate. Later, subsequent client connections without certificate do not exhibit the same behaviour. If the pattern reoccurs (... ---> client-with-cert ---> followed by client-without-cert), the story repeats. There is also a memory leak in this - when I looped the client to establish hundreds of sequential SSL connections, the residental memory footprint of php server process was ever increasing. When I switched my App server to HTTP protocol and repeated the test the memory leak was not present anymore. And I did openssl_x509_free() call on peer_certificate resource upon client disconnect. On 21 February 2010 00:05, Pierre Joye wrote: > hi, > > Is it not suppose to work already? As your patch basically does what > is done earlier in the code if match fails. If there is a bug in this > area, we should fix instead of adding the same thing later :) > > I will check this issue next week. > > Btw, there is no chance to get this in 5.2.13 or 5.3.2 at this stage, > it is too late in the process. > > Thanks for your work! > > Cheers, > > On Sat, Feb 20, 2010 at 8:56 PM, Bostjan Skufca wrote: >> Hi! >> >> I've created a patch that enables PHP to do "limited wildcard >> matching" if CN_match option in stream context is specified as >> '*.example.org'. >> Also I have filled a bug report for this, here: >> http://bugs.php.net/bug.php?id=51100 >> >> Patch is here: >> http://source.a2o.si/php/php-ext-openssl-CN_match-wildcard.diff >> >> It was made against 5.2.12 but I checked it with SVN: >> - for 5.2 branch the offset is only +6 lines >> - for trunk it is cca +800 lines >> >> Can you include it in 5.2.13 release and 5.3? I know the former is >> already in RC stage but this does can't break anything I believe. >> >> Best regards, >> b. >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > -- > Pierre > > @pierrejoye | http://blog.thepimp.net | http://www.libgd.org >