• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Enable HTTP Public Key Pinning (HPKP) Nginx With report-uri

By Abhishek Ghosh July 19, 2016 7:03 am Updated on July 19, 2016

Enable HTTP Public Key Pinning (HPKP) Nginx With report-uri

Advertisement

Previously, we have talked about HTTP Public Key Pinning (HPKP). HPKP is a security feature is to prevent fraud TLS certificates. Here Are the Steps to Enable HTTP Public Key Pinning (HPKP) on Nginx. We are using Ubuntu 16.04 LTS and latest version of Nginx. Reader will need to adjust some come commands for non deb GNU/Linux distro.

 

What is HTTP Public Key Pinning (HPKP) and Why We Need?

 

If a bad steal the CA’s private key and browser trusts the certificate, the bad can forge valid certificates for any website. So performing a man-in-the-middle (MITM) attack against every website is not impossible. HTTP Public Key Pinning (HPKP) significantly decrease the risk of MITM by allowing website operators to limit the certificates that can participate in their website’s chain of trust and to detect in-progress attacks.

HTTP Public Key Pinning (HPKP) is a security measure for the HTTPS websites to nullify the chance of impersonation by script-kiddies using fraudulent certificates. Nginx web server will serve a list of public key hashes by header, client browser will expect that the server will use one or more of those public keys in its certificate chain. HTTP Public Key Pinning (HPKP) is standardized in RFC 7469. The Nginx Server will communicate to the HPKP policy to the user agent via an HTTP response header field named Public-Key-Pins or Public-Key-Pins-Report-Only. The HPKP policy specifies :

Advertisement

---

  1. hashes of the subject public key info of one of the certificates in the website’s authentic X.509 public key certificate chain
  2. at least one backup key
  3. a time duration which the user agent shall enforce public key pinning via max-age directive
  4. optional includeSubDomains directive to include all subdomains
  5. optional report-uri directive with URL where to send pinning violation reports.

At least one of the public keys of the certificates in the certificate chain needs to match a pinned public key in order for the chain to be considered valid by the user agent. At the time of publishing this guide, RFC 7469 allowed hash algorithm SHA-256. Hashes for HPKP policy can be generated by shell commands or third-party tools. The HTTP Public Key Pinning (HPKP) will not be valid without minimum one backup key. Report URI should not be on same domain.

 

Steps to Enable HTTP Public Key Pinning (HPKP) : Nginx

 

Users can register for report-uri.io‘s free service. You will get few of the needed stuffs :

  1. HTTP Public Key Pinning keys
  2. Reporting URI service
  3. Testing tools

 

Technically, we can generate it with this command, where our web server’s certificate is www.thecustomizewindows.com.csr and we are at that directory :

Vim
1
openssl req -inform pem -pubkey -noout < www.thecustomizewindows.com.csr | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64

You will get something as output like :

Vim
1
BJKSF/6L2QXz4xK6MVj2RTiyPlFzQx3NcpuxnuqdABk=

That is “KEY”.

More detailed steps are written on our old guide. report.io service does the work. We need minimum another TLS certificate or any other web server specific certificate to run the above command to get another “KEY”. The second one is “Backup Key”. Further information can be found on :

Vim
1
2
https://scotthelme.co.uk/guidance-on-setting-up-hpkp/
https://developer.mozilla.org/en/docs/Web/Security/Public_Key_Pinning

Normally, users use /etc/nginx/sites-available/default file for Nginx we save site configuration. We have to add in this format for Nginx with add_header directive :

/etc/nginx/sites-available/default
Vim
1
add_header Public-Key-Pins 'pin-sha256="Paste-first"; pin-sha256="Paste-second"; report-uri="https://9fe34499a39b5130fa25da9e401e04a0.report-uri.io/r/default/hpkp/enforce" max-age=5184000; includeSubDomains';

Run nginx config test and restart Nginx. Test with SSL Lab’s test. You can test our header :

Enable-HTTP-Public-Key-Pinning-(HPKP)-Nginx-With-report-uri

~
Vim
1
curl -I https://thecustomizewindows.com | grep Public-Key-Pins

You’ll get the response :

~
Vim
1
Public-Key-Pins: pin-sha256="snqzW9Bwdb/++vjcA36+kbP/qaVMmnB9ckuI3qAkihQ="; pin-sha256="BJKSF/6L2QXz4xK6MVj2RTiyPlFzQx3NcpuxnuqdABk="; report-uri="https://9fe34499a39b5130fa25da9e401e04a0.report-uri.io/r/default/hpkp/enforce"; max-age=5184000; includeSubDomains

Tagged With public-key-pins nginx , nginx hpkp report uri , nginx hpkp , https://thecustomizewindows com/2016/07/http-public-key-pinning-hpkp-nginx/ , how to set nginx to enforce http public key pinning that helps preventing man-in-the-middle attacks , enabling hpkp ubuntu , Enable public key pinning , enable key pinning with Gandi certificate , Dr abshiek ghosh , dentist Dr abhisek ghosh
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Enable HTTP Public Key Pinning (HPKP) Nginx With report-uri

  • Safer Value of HPKP and HSTS (And Why You Should Avoid)

    Here Are Possible Safer Value of HPKP and HSTS For Apache2 and Discussion on And Why You Should Avoid Them on Production Site.

  • Generate CSR, Private Key With SHA256 Signature

    Here is how to generate CSR, Private Key with SHA256 signature with OpenSSL for either reissue or new request to get SSL/TLS Certificate.

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Public Key Pinning Support Nginx Ubuntu Cloud Server

    Here is a guide for enabling Public Key Pinning Support Nginx Ubuntu Cloud Server, which is essentially an advanced step for HSTS setup.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is the Push and Pull Model (Marketing/Sales)?December 7, 2023
  • Legal and Moral Aspects of Data MiningDecember 6, 2023
  • How Decision Support System WorksDecember 6, 2023
  • Types of Classification MethodsDecember 5, 2023
  • Time Series Analysis: OverviewDecember 5, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy