<div dir="ltr">Been working for a couple hours on an addition to the SSL module that would help users implement HPKP (<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning">https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning</a>).<div><br></div><div>The idea is to add a directive that would be easily configurable to have nginx present the appropriate PKP header on HTTP responses. Rather than continuing to work on this in a vacuum though, I thought maybe I should chime in on here to discuss the desirability of such a feature and get some consensus about the directive's API.</div><div><br></div><div>Having implemented HPKP in a few environments, one of the more frustrating problems is the need to extract public key data from a certificate or key and hardcode it into an add_header directive. Given that nginx already has access to the public key data for at least one possible pin (given TLS enabled and configured properly) in memory, it would seem to make sense to just have nginx handle this.</div><div><br></div><div>So that's the motivation. The things that are configurable in the HTTP PKP header are:</div><div><br></div><div>1 or more pins, extracted from public key information</div><div>max-age, a number of seconds that the pins are valid</div><div>includeSubdomains, an optional flag</div><div>reportUri, an optional url for the browser to report pin validation failures</div><div><br></div><div>So the proposal would be to have some new directives:</div><div><br></div><div>ssl_hpkp (on/off flag directive, default off)</div><div>ssl_hpkp_pins (variable args, possibly string filenames for more cert/keys to use, need help here)</div><div>ssl_hpkp_max_age (number of seconds, default of 1)</div><div>ssl_hpkp_include_subdomains (on/off flag directive, default off)<br></div><div>ssl_hpkp_report_uri (string directive for optional reporting url, default empty)<br></div><div><br></div><div>Of these, the only one I think is difficult is the one concerning pins. So I'd love to see suggestions for that.</div><div><br></div><div>In general, let me know what you all think.</div></div>