• 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 413 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 (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 Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023

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, February 1, 2023, https://thecustomizewindows.com/2016/07/http-public-key-pinning-hpkp-nginx/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT