Skip to main content

Application to generate x509 certificates and sign models with PKCS#7 standard

http://bitbucket.org/bearstech/django-signature/

Beta : not really for production use

Features :

  • PKI :

    • Generate (or load) RSA keys and store them in Django models

    • Generate x509 certificates and store them in Django models

    • Load x509 certificat and find relations with other Certificates and Keys

    • Generate (or load) x509 Requests and store them in Django models

    • Generate self-signed x509 for root CA

    • Verify certificate chain (with CRLs)

    • Sign Certificate Requests

  • Digital signature

    • Sign/verify text with PKCS#7 standard

    • Sign/verify simple modelswith PKCS#7 standard

    • Support FileField (with sha512 digest)

  • Good test coverage

Todo :

  • Sign complex models

  • Generate indexes with OpenSSL.generate_index()

  • Improve configuration

  • Cert load with renew

  • … and much more

Examples :

There is an simple PKI example:

from signature.models import Key, Certificate, CertificateRequest
from datetime import datetime

ca_pwd = "R00tz"
c_pwd = "1234"

# CA and Client keys
ca_key = Key.generate(ca_pwd)
c_key = Key.generate(c_pwd)

# CA Cert
ca_cert = Certificate()
ca_cert.CN = "Admin"
ca_cert.C = "FR"
ca_cert.key = ca_key
ca_cert.days = 150
ca_cert.is_ca = True
ca_cert.generate_x509_root(ca_pwd)
ca_cert.save()

# Client's request
rqst = CertificateRequest()
rqst.CN = "World Company"
rqst.C = "FR"
rqst.key = c_key
rqst.sign_request(c_pwd)
rqst.save()

# Sign client's request and return certificate
# (you can give to Client's certificate CA capabilities with ca=True)
c_cert = ca_cert.sign_request(rqst, 150, ca_pwd, ca=False)

# Verify created certificate :
c_cert.check()

# Revoke certificate :
c_cert.revoke(c_cert, ca_pwd)

# Import a Key / Certificate:
imported = Key.new_from_pem(pem_str, passphrase="gigowatt", user=None)
imported = Certificate.new_from_pem(pem_str)

For more examples, see SignaturePKITestCase into tests/test_project/apps/testapp/tests.py

There is an simple signature example:

# Sign Text
text = "This is a data"
data_signed = c_cert.sign_text(text, c_pwd)
result = c_cert.verify_smime(data_signed)

# Sign Model (get text)
auth1 = Author(name="Raymond E. Feist", title="MR")
data_signed = c_cert.sign_model(auth1, c_pwd)
result = c_cert.verify_smime(data_signed)

# Sign Model (get Signature)
auth1 = Author(name="Raymond E. Feist", title="MR")
signed = c_cert.make_signature(auth1, self.c_pwd)
signed.check_pkcs7(signed)

For more examples, see SignatureTestCase into tests/test_project/apps/testapp/tests.py

Tests :

  • cd tests

  • python bootstrap.py

  • ./bin/buildout.py -v

  • ./bin/test-1.2 or ./bin/test-1.1

Requirements :

Metadata

Release files for django-signature 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-signature 0.3.1
File Size Uploaded
django-signature-0.3.1.tar.gz 46.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-signature 0.3.1
File Interpreter ABI Platform
django-signature-0.3.1.linux-x86_64.tar.gz Details

Total release size: 84.1 kB

Release files / django-signature-0.3.1.tar.gz

Download URL django-signature-0.3.1.tar.gz
Size 46.4 kB
Tags Source
SHA-256 checksum
How to use checksums
61229c924fc824ecd50dd4877bdc342e6c7cc74c45d1e2815bfcc89ef8fb6ca4
BLAKE2b-256 checksum
How to use checksums
2e09b06457f8a659afcfcdf6b2c75aa378d6d8f5a62daa0312a4cf5818bb023a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django-signature-0.3.1.linux-x86_64.tar.gz

Download URL django-signature-0.3.1.linux-x86_64.tar.gz
Size 37.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ea0ef57af784b7157d9775c4f77b7dfc01e55aa2ce9bb40b58dcf47772f63b59
BLAKE2b-256 checksum
How to use checksums
ab29436caa6ba6d7e674371fa115c20e29e835e9859027a0cb6380221e0ef4b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3

1 release file

0.2.1

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page