Django应用程序生成和签名模型。

django-signature的Python项目详细描述


使用pkcs 7标准生成x509证书和签名模型的应用程序

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

beta:不是真正的生产用途

特点:

  • 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

待办事项:

  • Sign complex models
  • Generate indexes with OpenSSL.generate_index()
  • Improve configuration
  • Cert load with renew
  • … and much more

示例:

有一个简单的pki示例:

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)

有关更多示例,请参见signaturepkitestcase into tests/test_project/apps/testapp/tests.py

有一个简单的签名示例:

# 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)

有关更多示例,请参见signatureTestCase into tests/test_project/apps/testapp/tests.py

测试:

  • cd tests
  • python bootstrap.py
  • ./bin/buildout.py -v
  • ./bin/test-1.2 or ./bin/test-1.1

要求:

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
spring引导服务器忽略java上载请求   java多个驼峰路由会导致大量线程吗?   java 安卓单签入回收器gridLayout管理器   Java中指向类的不同实例的对象数组   java的启动/停止和打开/关闭等分组功能是否违反了单一责任原则?   java hibernate组件映射与自定义值类型   java如何使用不同的JDK在Jenkins作业中使用JDK8   java从匹配器获取字符串的特定部分   java通过在Spark数据框内的数组列中映射来创建新列   servlet的java Tomcat配置   java多个活动不在一个应用程序安卓 studio中   javajsf:view beforePhase在我离开页面时多次触发   javascript如何使用“java脚本”进行加密,使用和“java”进行解密   java My App不是从URL ASPX读取简单的JSON   java在RESTish web服务中应用DDD原则