mirror of
https://github.com/DarrylNixon/CrowdTLS-server.git
synced 2024-09-22 18:19:43 -07:00
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import datetime
|
|
from typing import List
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import LargeBinary
|
|
from sqlmodel import Field
|
|
from sqlmodel import Relationship
|
|
from sqlmodel import SQLModel
|
|
|
|
|
|
class DomainCertificateLink(SQLModel, table=True):
|
|
fqdn: Optional[str] = Field(default=None, foreign_key="domain.fqdn", primary_key=True)
|
|
fingerprint: Optional[str] = Field(default=None, foreign_key="certificate.fingerprint", primary_key=True)
|
|
|
|
|
|
class Domain(SQLModel, table=True):
|
|
fqdn: str = Field(primary_key=True)
|
|
root: str
|
|
tld: str
|
|
certificates: Optional[List["Certificate"]] = Relationship(
|
|
back_populates="domains", link_model=DomainCertificateLink
|
|
)
|
|
|
|
|
|
class Certificate(SQLModel, table=True):
|
|
fingerprint: str = Field(index=True, primary_key=True)
|
|
version: int
|
|
serial_number: str
|
|
signature: bytes = Field(default_factory=LargeBinary)
|
|
issuer: str
|
|
not_valid_before: datetime.datetime
|
|
not_valid_after: datetime.datetime
|
|
subject: str
|
|
subject_public_key_info: str
|
|
raw_der_certificate: bytes = Field(default_factory=LargeBinary)
|
|
domains: Optional[List[Domain]] = Relationship(back_populates="certificates", link_model=DomainCertificateLink)
|