Skip to main content

django-ca plugin for Certificate Management over CMS (CMC)

Project description

django-ca-cmc

A plugin for django-ca implementing a subset of RFC 5272 - Certificate Management over CMS (CMC).

The CMC parts of the code are based on SUNET/pkcs11_ca.

Current deployment scenario

At present, you need both django-ca-cmc and django-ca checked out, to build the necessary images. This is at present pretty convoluted (primarily because we require a release of django-ca first), but will get better soon:

Initial setup

Follow the [Docker Compose quickstart guide] (https://django-ca.readthedocs.io/en/latest/quickstart/docker_compose.html).

If you do not want to enable TLS:

  • Skip generating DH parameters.
  • Don't set NGINX_* variables in .env.

Configuration file

Nothing special required.

Add compose.yaml

Get version 2.2.0.

Add compose.override.yaml

Nothing special is needed (everything is included in the Docker image).

Add .env file

Important: You need to set

DJANGO_CA_IMAGE=ghcr.io/mathiasertl/django-ca-cmc
DJANGO_CA_VERSION=main

CMC setup

Add a CMC client certificate:

cat client.pem | docker compose exec -T frontend manage cmc_add_client -

You can access CMC for any CA at /cmc/<serial>/ (get serials with manage list_cas). To enable the /cmc01 endpoint you need to tell it which CA to use by serial: Add the CA_DEFAULT_CMC_SERIAL to localsettings.yaml and update your setup.

Verify setup (a GET request will simply confirm that you reach the right endpoint):

curl http://localhost/cmc01

View configuration

This app includes one class-based view.

The Docker image includes a default URL configuration (see conf/20-django-ca-cmc.yaml in this repository) so that it will serve the following URL paths:

  • /cmc01 - will sign certificates using the CA configured via the CA_CMC_DEFAULT_SERIAL setting.
  • /cmc/<serial>/ - will sign certificates using the CA identified via the serial in the URL path.

In both URL paths, the response will be signed by the same CA that signs the certificates. This can be changed using the CA_CMC_DEFAULT_RESPONDER_SERIAL setting.

Manual view configuration

This chapter is only relevant if you want to configure your own URL paths.

If serial is passed via the URL path, the CA identified by this serial will be used. If the serial is not in the URL path, you can override the CA_CMC_DEFAULT_SERIAL setting via the serial view configuration. You can also overwrite CA_CMC_DEFAULT_RESPONDER_SERIAL using repsonder_serial.

Example urls.py:

from django.urls import path

from django_ca_cmc.views import CMCView

urlpatterns = [
    # Use CA_CMC_DEFAULT_SERIAL and CA_CMC_DEFAULT_RESPONDER_SERIAL
    path('/cmc01', CMCView.as_view()),
  
    # Use special serials for signing certs and responses:
    path('/cmc01', CMCView.as_view(serial="ABC", responder_serial="DEF")),
]

Settings

  • CA_CMC_COPY_CSR_EXTENSIONS_BLACKLIST: (default: [...])

    List of extensions that will never be copied from a CSR. By default, includes OIDs for the authorityInformationAccess, authorityKeyIdentifier, basicConstraints, cRLDistributionPoints, and subjectKeyIdentifier extensions.

    See the docs for a list of common ExtensionOIDs.

    Example value:

    CA_CMC_COPY_CSR_EXTENSIONS_BLACKLIST = ["2.5.29.32"]
    
  • CA_CMC_DEFAULT_RESPONDER_SERIAL

    Serial of the CA to use for signing responses if it is not configured by the view. If neither is set, the CA used for signing certificates will be used.

  • CA_CMC_DEFAULT_SERIAL

    Serial of the CA to use for signing certificates if the CA is not configured via the view or the URL.

  • CA_CMC_DIGEST_ALGORITHM (default: "sha256")

    Algorithm used for message digest generation. Valid values are any SHA2 or SHA3 algorithms from the hashlib module (e.g. "sha3_256").

  • CA_CMC_COPY_UNRECOGNIZED_CSR_EXTENSIONS (default: False)

    Set to True if you want clients to be able to send extensions not recognized by cryptography and have them added to the certificate.

Open questions

  • https://github.com/SUNET/pkcs11_ca/blob/main/src/pkcs11_ca_service/cmc.py#L177 --> failed is True if an exception was raised. Is this maybe the opposite of what you would want?
  • convert_rs_ec_signature() -- are we sure this actually works? it seems to be somewhat changing the value, but unclear in what way. r & s values are different from what cryptograph produces
  • digest_algorithm in response: upstream it's alwasy sha256 (via oid), but https://www.rfc-editor.org/rfc/rfc5753.html, section 2.1.1 says digest algorithm must match signatureAlgorithm, which depends on curve used.
  • get_signed_digest_algorithm(): I cannot see actual relation between curve and hash documented anywhere. Can we just use SHA-512?

Noted improvements/changes over existing solution

  • Client certificate management via CLI/admin interface.
  • Client certificate expiration taken into account.
  • CMC certificate chain now includes full bundle (first FIXME in create_cmc_response)
  • RSA keys: Decoupling of key length and signature algorithm

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_ca_cmc-0.0.1.tar.gz (76.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ca_cmc-0.0.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file django_ca_cmc-0.0.1.tar.gz.

File metadata

  • Download URL: django_ca_cmc-0.0.1.tar.gz
  • Upload date:
  • Size: 76.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for django_ca_cmc-0.0.1.tar.gz
Algorithm Hash digest
SHA256 dd2e9c1ff222c0443abe40634c26198c1bf1de5e7384b66427335d36031841e6
MD5 ce1c0a9a88cb3ab0bbd73de86087704c
BLAKE2b-256 a054653f7340ed0e4f4a26dfb16ad42c7096adaf53cf7f96d65d53b359c99415

See more details on using hashes here.

File details

Details for the file django_ca_cmc-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_ca_cmc-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for django_ca_cmc-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 918e3b71878061eedeb97036a9413c509d00f3dfc48d7a54866896170638a7a9
MD5 79485c0d7630bddd8f29f60ba513b342
BLAKE2b-256 2349f0a4bb1aa36ac6c82b2adea3c3f276260e6cd30695496a950335d7886692

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page