From d5fbbf547203061b1eaafbe80c4538a37fce5a34 Mon Sep 17 00:00:00 2001 From: Mishael A Sibiryakov Date: Thu, 20 Oct 2016 12:05:32 +0300 Subject: Add some tolerance (RFC2616 sec. 19.3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi all. We're implementing client certificate authentication with nginx and unicorn.  Nginx configured in the following way: proxy_set_header X-SSL-Client-Cert $ssl_client_cert; When client submits certificate and nginx passes it to the unicorn, unicorn responds with 400 (Bad Request). This caused because nginx doesn't use "\r\n" they using just "\n" and multilne headers is failed to parse (I've added test). Accorording to RFC2616 section 19.3: https://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.3 "The line terminator for message-header fields is the sequence CRLF. However, we recommend that applications, when parsing such headers, recognize a single LF as a line terminator and ignore the leading CR." CRLF changed to ("\r\n" | "\n") Github commit https://github.com/uno4ki/unicorn/commit/ed127b66e162aaf176de05720f6be758f8b41b1f PS: Googling "nginx unicorn ssl_client_cert" shows the problem.  --- ext/unicorn_http/unicorn_http_common.rl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/unicorn_http/unicorn_http_common.rl') diff --git a/ext/unicorn_http/unicorn_http_common.rl b/ext/unicorn_http/unicorn_http_common.rl index cc1d455..0988b54 100644 --- a/ext/unicorn_http/unicorn_http_common.rl +++ b/ext/unicorn_http/unicorn_http_common.rl @@ -4,7 +4,7 @@ #### HTTP PROTOCOL GRAMMAR # line endings - CRLF = "\r\n"; +  CRLF = ("\r\n" | "\n"); # character types CTL = (cntrl | 127); -- cgit v1.2.3-24-ge0c7