• 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 , paperuri:(2f8cd89bb57714e0c4bae87a88df23b1) , nginx hpkp report uri , nginx hpkp , 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

This Article Has Been Shared 707 Times!

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

  • SELinux and Security in the Context of Cloud Servers

    SELinux Was Developed By United States National Security Agency (NSA). SELinux and Security in the Context of Cloud Servers Can Be Questionable.

  • Security Concerns of Server Virtualization and Solutions

    Recent discovery of VENOM and related critical bugs in the Xen, KVM, and native QEMU virtual machine platforms again brought the topic Security Concerns of Server Virtualization in to lime light. VENOM was unknown, from Heartbleed, what we have learned is quite clear – frankly there is nothing to do with the unknown, undiscovered bugs […]

  • Logjam by NSA Threatens the Security of HTTPS

    Logjam, which allows man-in-the-middle attacker to downgrade the vulnerable TLS connections, apparently created by NSA Threatens the Security of HTTPS.

  • How to Add DMARC, DKIM, SFP to Avoid Email Spoofing

    Commonly, Transactional Email Services Like Mandrill is used With Google Apps. Here is How to Add DMARC, DKIM, SFP to Avoid Email Spoofing.

  • OCSP Stapling Nginx : Working Guide to Enable

    Many Users Complain of Not Working OCSP Stapling in Nginx or Facing Chain Error. Here is Working Step by Step Guide on OCSP Stapling Nginx.

Additionally, 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 (22.1K 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

  • Big Data in Sports May 20, 2022
  • FaaS Versus PaaS Deployment: What You Should Know May 18, 2022
  • What Is A Digital Media Consultancy? May 17, 2022
  • How Artificial Intelligence (AI) Is Changing The Way We Play Bingo May 16, 2022
  • Why You Need A Big Data Consultant May 15, 2022

About This Article

Cite this article as: Abhishek Ghosh, "Enable HTTP Public Key Pinning (HPKP) Nginx With report-uri," in The Customize Windows, July 19, 2016, May 21, 2022, https://thecustomizewindows.com/2016/07/http-public-key-pinning-hpkp-nginx/.

Source:The Customize Windows, JiMA.in

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Privacy Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

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

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