Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:06:12+00:00 2026-06-07T15:06:12+00:00

What is the best way to debug a Django app that runs on top

  • 0

What is the best way to debug a Django app that runs on top of TLS/SSL?

Background:

I have a Django web app that uses X.509 client side certificates for authentication. When running under Apache, my app can only be reached via HTTPS. Clients that connect to the app provide a client side certificate which Apache validates and then forwards to the app in an environment variable. The app parses the certificate and provides access controlled content.

So far, I have only been able to debug the app under regular HTTP, with “./manage.py runserver”. I have simulated an HTTPS connection by using a custom view handler middleware that kicks in, in debug mode. The view handler adds information to the request, similar to the information that would be parsed out of an actual client side certificate when run under HTTPS.

It would make debugging much easier for me if I could debug with the actual client side certificates that clients provide when connecting via HTTPS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:06:13+00:00Added an answer on June 7, 2026 at 3:06 pm

    We use nginx in front of Django, with client certificate checking. NGINX does the SSL termination, client cert validation, and checking against revocation list. The client cert fields are passed in header variables up to the django app.

    So then our django app doesn’t receive the cert, it just looks at the header variables. I think the same mechanism applies in Apache.

    For clients accessing the development server (e.g. ‘./manage.py runserver’), we simply have a special case in the client. Example of a python client:

      if (proto == "https"):
        conn = http.client.HTTPSConnection( "cert."+webhost+":"+port,
                                            key_file = certfile, cert_file = certfile)
        headers = {}
      else:
        # fake client for local connections.  pass cert info in headers, as it would come
        # out of nginx
        conn = http.client.HTTPConnection( webhost+":"+port)
        headers = { 'X_SSL_CLIENT_S_DN':'/C=US/ST=California/O=yyyy/CN=zzzz',
                    'X_SSL_CLIENT_I_DN':'/C=US/ST=California/O=xxxx/CN=wwww',
                    'X_SSL_CLIENT_SERIAL':hex(serialnum),
                    'USER_AGENT':"test client user agent",}
    

    For unit tests, we do the same thing using the Django test client:

      from django.test.client import Client
      self.client = Client()
      response = self.client.get(url, data,
                    **{
                    'HTTP_X_SSL_CLIENT_S_DN':'/C=US/ST=California/O=yyyy/CN=zzzz',
                    'HTTP_X_SSL_CLIENT_I_DN':'/C=US/ST=California/O=xxxx/CN=wwww',
                    'HTTP_X_SSL_CLIENT_SERIAL':hex(serialnum),
                    'HTTP_USER_AGENT':"test client user agent",
                    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that I only have one monitor, what's the best way to debug a
What is the best way to debug a CRASHING flash app ? (no exception,
What is the best way to get something similar to django-debug-toolbar working on Google
What's the best way to debug custom User Scripts (aka Greasemonkey) in Chrome? Is
The best way to explain my problem is by a example. I have a
The best way of describing this is I have a table of people with
Sometimes the best way to debug something is to print some stuff to the
What is the best way to debug an android application? Every once in a
I have been doing what it was suggested in Best way to dynamically set
What's the best way to debug a webworker? My worker appears to be failing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.