Easy CA management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from peewee import *
  4. import os
  5. import json
  6. from models.authority import Authority
  7. from paths import *
  8. class Certificate(Model):
  9. """
  10. """
  11. signed_by = ForeignKeyField(
  12. Authority,
  13. related_name = 'signed_certificates',
  14. )
  15. cert_id = CharField(
  16. index = True,
  17. unique = True,
  18. help_text = 'id shared with the sign request',
  19. )
  20. date_issued = DateTimeField(
  21. help_text = 'certificate\'s issue date',
  22. )
  23. receiver = CharField(
  24. help_text = 'hostname or list of user for this certificate',
  25. )
  26. serial_number = IntegerField(
  27. help_text = 'certificate\'s progressive number',
  28. )
  29. validity_interval = CharField(
  30. help_text = 'how long will the certificate be valid',
  31. )
  32. def __repr__(self):
  33. return ( "%s %s" % ( str(self.__class__.__name__), str(self.cert_id) ) )
  34. def __bool__(self):
  35. return os.path.exists(self.path)
  36. @property
  37. def path(self):
  38. return os.path.join(OUTPUT_PATH, self.cert_id + '-cert.pub')