<div dir="ltr"><div><div><div><div><div><div>Hello Maxim,<br><br></div>Thanks for comments!<br></div>Please find ammended patch attached.<br><br></div>As to example of usage: it's a real-world use-case - one of our customers do want to see these values on backend server for whatever purpose.<br></div>But your example also have a right to be aplicable sometime.<br><br></div>Best wishes,<br></div>Andrey<br><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 7 September 2015 at 21:04, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<span class=""><br>
On Mon, Sep 07, 2015 at 08:18:29PM +0300, Andrey Kulikov wrote:<br>
<br>
> Hello,<br>
><br>
> Nginx SSL module allow to use some variables:<br>
> <a href="http://nginx.org/en/docs/http/ngx_http_ssl_module.html#variables" rel="noreferrer" target="_blank">http://nginx.org/en/docs/http/ngx_http_ssl_module.html#variables</a><br>
> But sometimes tey are not enough.<br>
><br>
> Please find attached patch, adding two more:<br>
> $ssl_client_not_before - Validity date from client certificate 'Not Before'<br>
> $ssl_client_not_after - Validity date from client certificate 'Not After'<br>
><br>
> After applying changes you may use them in configuration along with other<br>
> variables:<br>
><br>
> location /test_headers/ {<br>
> proxy_set_header X-ClientCert-SubjectSerial $ssl_client_serial;<br>
> proxy_set_header X-ClientCert-NotBefore $ssl_client_not_before;<br>
> proxy_set_header X-ClientCert-NotAfter $ssl_client_not_after;<br>
> proxy_pass <a href="http://192.168.88.156/" rel="noreferrer" target="_blank">http://192.168.88.156/</a>;<br>
> }<br>
><br>
> And it will appears in (in this case) in proxied content in the following<br>
> form:<br>
><br>
> X-ClientCert-SubjectSerial: 120005C82FBE782D06D89FF14800000005C82F<br>
> X-ClientCert-NotBefore: Jul 9 22:20:31 2015 GMT<br>
> X-ClientCert-NotAfter: Oct 9 22:30:31 2015 GMT<br>
><br>
><br>
> Tested on 1.8.0, tested that it can be cleanly applied to 1.9.4.<br>
><br>
> Feel free to ask any questions regarding this matter.<br>
<br>
</span>How do you expect these variables to be used? For some form of<br>
warning like "your certificate will expire soon, please update<br>
it"? Note that validity of the certificate was already checked at<br>
this point, these fields in particular, and that's not something a<br>
backend server needs to test.<br>
<br>
See also <a href="http://nginx.org/en/docs/contributing_changes.html" rel="noreferrer" target="_blank">http://nginx.org/en/docs/contributing_changes.html</a> for<br>
some hints on how we would prefer submissions to be done.<br>
<br>
[...]<br>
<br>
> + return NGX_OK;<br>
> +}<br>
> +<br>
> +ngx_int_t<br>
> +ngx_ssl_get_client_not_after(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)<br>
<br>
Two empty lines between functions, please.<br>
<br>
[...]<br>
<br>
> + return NGX_OK;<br>
> +}<br>
> +<br>
> +ngx_int_t<br>
> ngx_ssl_get_fingerprint(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)<br>
<br>
Same here.<br>
<br>
[...]<br>
<br>
> --- a/src/http/modules/ngx_http_ssl_module.c<br>
> +++ b/src/http/modules/ngx_http_ssl_module.c<br>
> @@ -307,6 +307,12 @@ static ngx_http_variable_t ngx_http_ssl_vars[] = {<br>
> { ngx_string("ssl_client_verify"), NULL, ngx_http_ssl_variable,<br>
> (uintptr_t) ngx_ssl_get_client_verify, NGX_HTTP_VAR_CHANGEABLE, 0 },<br>
><br>
> + { ngx_string("ssl_client_not_before"), NULL, ngx_http_ssl_variable,<br>
> + (uintptr_t) ngx_ssl_get_client_not_before, NGX_HTTP_VAR_CHANGEABLE, 0 },<br>
> +<br>
> + { ngx_string("ssl_client_not_after"), NULL, ngx_http_ssl_variable,<br>
> + (uintptr_t) ngx_ssl_get_client_not_after, NGX_HTTP_VAR_CHANGEABLE, 0 },<br>
> +<br>
> { ngx_null_string, NULL, NULL, 0, 0, 0 }<br>
> };<br>
<br>
It should be better to put these variables after $ssl_client_serial,<br>
much like the functions itself.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/" rel="noreferrer" target="_blank">http://nginx.org/</a><br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</font></span></blockquote></div><br></div></div></div></div>