Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mTLS with nginx and python #1583

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

HarryPaulo
Copy link

@HarryPaulo HarryPaulo commented Sep 18, 2024

When we are going to integrate 2 systems where we need a high level of security between the two ends of the communication, we must use mTLS to verify and validate that the requests received from the client have the certificate...
Normally this type of integration does not work with HMAC, it must use mTLS.

image

So, I looked for the most efficient and flexible configuration to apply this, thinking that on a server with a "bench" we will have more than one site and each site can have more than one integration enabled with mTLS certificate configured and each integration can have your own certificate

image

The ngnix configuration was chosen:
ssl_verify_client optional_no_ca
optional_no_ca: requests the client certificate but does not require it to be signed by a trusted CA certificate. This is intended for the use in cases when a service that is external to nginx performs the actual certificate verification. The contents of the certificate is accessible through the $ssl_client_cert variable.

"proxy_set_header SSL_CLIENT_CERT $ssl_client_cert;": allows you to get the certificate from the header, using a relative variable.
image

So with this config, i can made a validade on Python loading the certificate configured on relative integration and confirming the identity:

image

ps: Maybe there are some more points to be implemented, I will be putting my application into production in a few days or weeks...

I am open to suggestions

Copy link

sonarcloud bot commented Sep 18, 2024

@HarryPaulo
Copy link
Author

I'm working on it, and I think this first change wasn't a good one because it's in the base url location / {...}

I'm studying and exploring something that fits better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant