Path converters
django-ca provides several path converters that you can use in your own URL configurations.
django-ca-hex
A path converter that accepts hex values, possibly with semicolons. It does not sanitize the input value in any way.
This converter is intended for hex-encoded serials in URLs that are retrieved and used programmatically. For example, the OCSP endpoint is encoded in the certificate itself, and clients will call it without user interaction. django-ca already takes care of sanitizing the URL in the certificate, so it should never be called with semicolons in the first place.
django-ca-serial
A path converter that accepts hex values, but sanitizes input values by removing semicolons and leading zeros.
The path element can be used to retrieve CertificateAuthority or
Certificate instances from the database.
For example, consider this URL configuration:
urls.pyfrom django.urls import path
from . import my_views
urlpatterns = [
path("<django-ca-serial:serial>/", my_views.MyView.as_view())
]
Your view implementation can then use the serial to fetch data from the database:
from django.http import HttpRequest, HttpResponse
from django.views.generic.base import View
from django_ca.models import CertificateAuthority
class MyView(View):
def get(self, request: HttpRequest, serial: str) -> HttpResponse:
ca = CertificateAuthority.objects.get(serial=serial)
return HttpResponse(ca.name)
django-ca-base64
A path converter that accepts characters for base64-encoded values. Note that this converter does not decode data, as endpoints might need to return custom error responses in case of malformed data.
django-ca-acme-slug
A converter that accepts ACME slugs. This is used internally for the ACME implementation.