Using Mutual TLS (mTLS) Authentication | ngrok documentation (2024)

Mutual TLS Authentication (mTLS) is a method for providing security to sensitive applications in a zero trust security posture. This additional layer of security provides confidence by validating the identity of both the client and server before any transfer of data. In a majority of the TLS connections being made everyday, the client will verify the identity of the server confirming that the correct server is being accessed. For example, when accessing https://ngrok.com/docs, you will receive a certificate correctly identifying the server as ngrok.com.

mTLS adds an additional flow to the previous TLS server verification steps. The client will still verify the server's identity, but now the server will in turn also verify the identity of the client. By verifying the clients, the server owner is able to restrict access only to verified clients strengthening security.Using Mutual TLS (mTLS) Authentication | ngrok documentation (1)

This document will provide a quick start guide for how to enable mTLS on your ngrok hosted endpoints. For a deeper understanding for how mTLS is implemented within ngrok, reference the Mutual TLS module page.

Prerequisites

A certificate authority (CA) is required for mTLS. The CA is responsible for issuing and digitally signing certificates (client certificates). The CA will also be used to verify the authenticity of the certificates.

  1. CA certificate to be used by ngrok to verify the clients
  2. Client certificates signed by the CA used to access the endpoints

Users are responsible for providing the CA and client certificates, ngrok will not generate them. The CA certificate will be uploaded and hosted on the ngrok SaaS platform. The client certificates will need to be distributed to any client/device that will need to access the endpoint.

Most organizations will have their own certificate mangement infrastructure, examples are provided below for creating the CA and client certificates. These examples of certificate creation are optional, and provided for reference/demo purposes.

Example - Create the CA

Generate the CA private key, providing a strong passphrase is desirable.

Now we'll generate the CA certificate. Feel free to leave attribute fields blank by entering a period .. It's recommended to specify the CommonName, this will be used to identify the certificate authority.

openssl req -new -x509 -sha256 -days 365 -key ca.key -out ca.crt

Example - Create a Client Certificate

Generate the client private key

openssl genrsa -out ngrokclient.key 2048

Create a signing request for the client private key. Feel free to leave attribute fields blank by entering a period .. It's recommended to specify the CommonName, this will be used to identify the client certificate.

openssl req -new -key ngrokclient.key -out ngrokclient.csr

Use the CA certificate to sign the request and generate the client certificate

openssl \
x509 -req -days 365 -sha256 -in ngrokclient.csr \
-CA ca.crt -CAkey ca.key -set_serial 0x"$(openssl rand -hex 16)" -out ngrokclient.crt

Enable mTLS

With the prerequisites being met, let's see how simple it is to enable mTLS with ngrok. Examples for using either the Agent CLI or ngrok Cloud Edges are provided below.

Agent CLI

Specify the CA certificate when starting the tunnel.

ngrok http 80 --mutual-tls-cas ca.crt

The command starts a ngrok HTTPs endpoint forwarding traffic to port 80 on your localhost. The specified CA cert is uploaded to the ngrok SaaS platform securing the endpoint with mTLS protection. When the agent is stopped, the endpoint is removed and the uploaded CA cert will be purged from ngrok.

Cloud Edges

If using the Cloud Edges product, we'll need to upload the CA certificate creating a Certificate Authority object that will be referenced by the Cloud Edge mTLS module.From within the ngrok dashboard follow the next steps.

Upload CA cert

  • Navigate to Security --> TLS Certfiicate Authorities and click + Add a Certificate Authority.
  • Upload or Paste in the contents of the CA certificate and click Continue.

Enable mTLS on Edge

  • From within the ngrok dashboard, navigate to Cloud Edge --> Edges and select your existing Edge or click on + New Edge to create either a HTTPs or TLS edge.
  • Within the Edges configuration, select the Mutual TLS module and click Begin Setup
  • Click Attach Authority, select the previously uploaded CA, click Attach 1 Certificate Authority and then click Save.

Testing mTLS

To test that mTLS is working correctly, first try to access without specifying your client cert. A certificate error will be returned denying access to the endpoint.

curl https://<your_ngrok_endpoint>/

Now let's specify the client certificate and key when accessing the site. This will be successful verifying that your endpoint is protected with mTLS.

curl --cert ngrokclient.crt --key ngrokclient.key https://<your_ngrok_endpoint>/

Conclusion

mTLS is an extremely effective way to control who/what is able to access your endpoints. Utilizing the ngrok platform vastly simplifies the implementation of mTLS providing enhanced security for your endpoints in seconds.

Using Mutual TLS (mTLS) Authentication | ngrok documentation (2024)
Top Articles
Alternative Investments to Look Into: Know This - Gary Vaynerchuk
How do I get Ebay to call me back?
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Fr. Dewey Fisher

Last Updated:

Views: 6742

Rating: 4.1 / 5 (62 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Fr. Dewey Fisher

Birthday: 1993-03-26

Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

Phone: +5938540192553

Job: Administration Developer

Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.