1 |
fa03de5c
|
Captain_Trojan
|
from src.utils.file_anchor import FileAnchor
|
2 |
|
|
|
3 |
d2b0ef43
|
Stanislav Král
|
INMEMORY_DATABASE_FILE = ":memory:"
|
4 |
|
|
TEST_DATABASE_FILE = INMEMORY_DATABASE_FILE
|
5 |
07a6c869
|
David Friesecký
|
DB_DIR = "db"
|
6 |
|
|
DATABASE_FILE = f"{DB_DIR}/database_sqlite.db"
|
7 |
fa03de5c
|
Captain_Trojan
|
DATABASE_FILE_LOCATION = FileAnchor("aswi2021jmsd", DATABASE_FILE)
|
8 |
493022a0
|
Jan Pašek
|
DATETIME_FORMAT = "%d.%m.%Y %H:%M:%S"
|
9 |
2c96b4a5
|
David Friesecký
|
|
10 |
ed35ce72
|
David Friesecký
|
LOG_DIR = "logs"
|
11 |
07a6c869
|
David Friesecký
|
LOG_FILENAME = "application.log"
|
12 |
|
|
LOG_FILE = f"{LOG_DIR}/{LOG_FILENAME}"
|
13 |
1bdc90c0
|
David Friesecký
|
LOG_FILE_LOCATION = FileAnchor("aswi2021jmsd", LOG_FILE)
|
14 |
|
|
LOG_FORMAT = "%(levelname)-8s %(asctime)s - %(message)s"
|
15 |
ed35ce72
|
David Friesecký
|
LOG_NAME = "app_logger"
|
16 |
1bdc90c0
|
David Friesecký
|
|
17 |
163f57d0
|
David Friesecký
|
REV_REASON_UNSPECIFIED = "unspecified"
|
18 |
|
|
|
19 |
a0602bad
|
David Friesecký
|
# Types of certificates
|
20 |
2c96b4a5
|
David Friesecký
|
ROOT_CA_ID = 1
|
21 |
|
|
INTERMEDIATE_CA_ID = 2
|
22 |
|
|
CERTIFICATE_ID = 3
|
23 |
|
|
|
24 |
a0602bad
|
David Friesecký
|
# Usage types of certificates
|
25 |
2c96b4a5
|
David Friesecký
|
CA_ID = 1
|
26 |
|
|
SSL_ID = 2
|
27 |
|
|
SIGNATURE_ID = 3
|
28 |
|
|
AUTHENTICATION_ID = 4
|
29 |
993ee5a1
|
David Friesecký
|
DICT_USAGES = {CA_ID: False, SSL_ID: False, SIGNATURE_ID: False, AUTHENTICATION_ID: False}
|
30 |
|
|
|
31 |
b5114e4e
|
David Friesecký
|
# DB names of tables
|
32 |
993ee5a1
|
David Friesecký
|
TAB_CERTIFICATES = "Certificates"
|
33 |
|
|
TAB_PRIVATE_KEYS = "PrivateKeys"
|
34 |
|
|
TAB_CERTIFICATE_USAGES = "CertificateUsages"
|
35 |
bcdb15bd
|
David Friesecký
|
TAB_CERTIFICATE_TYPES = "CertificateTypes"
|
36 |
|
|
TAB_USAGE_TYPES = "UsageTypes"
|
37 |
b5114e4e
|
David Friesecký
|
|
38 |
|
|
# DB column names
|
39 |
|
|
COL_ID = "id"
|
40 |
2525db58
|
Captain_Trojan
|
COL_PK = "private_key"
|
41 |
b5114e4e
|
David Friesecký
|
|
42 |
993ee5a1
|
David Friesecký
|
# DB column names of Certificates table
|
43 |
b5114e4e
|
David Friesecký
|
COL_VALID_FROM = "valid_from"
|
44 |
|
|
COL_VALID_TO = "valid_to"
|
45 |
|
|
COL_PEM_DATA = "pem_data"
|
46 |
0e7c3096
|
David Friesecký
|
COL_COMMON_NAME = "common_name"
|
47 |
|
|
COL_COUNTRY_CODE = "country_code"
|
48 |
|
|
COL_LOCALITY = "locality"
|
49 |
|
|
COL_PROVINCE = "province"
|
50 |
|
|
COL_ORGANIZATION = "organization"
|
51 |
|
|
COL_ORGANIZATIONAL_UNIT = "organizational_unit"
|
52 |
|
|
COL_EMAIL_ADDRESS = "email_address"
|
53 |
1f75a8f5
|
David Friesecký
|
COL_REVOCATION_DATE = "revocation_date"
|
54 |
|
|
COL_REVOCATION_REASON = "revocation_reason"
|
55 |
6425fa36
|
David Friesecký
|
COL_DELETION_DATE = "deletion_date"
|
56 |
993ee5a1
|
David Friesecký
|
COL_TYPE_ID = "certificate_type_id"
|
57 |
47e0e828
|
David Friesecký
|
COL_PARENT_ID = "parent_certificate_id"
|
58 |
0e7c3096
|
David Friesecký
|
COL_PRIVATE_KEY_ID = "private_key_id"
|
59 |
b5114e4e
|
David Friesecký
|
|
60 |
993ee5a1
|
David Friesecký
|
# DB column names of PrivateKeys table
|
61 |
b5114e4e
|
David Friesecký
|
COL_PRIVATE_KEY = "private_key"
|
62 |
|
|
COL_PASSWORD = "password"
|
63 |
993ee5a1
|
David Friesecký
|
|
64 |
|
|
# DB column names of PrivateKey table
|
65 |
|
|
COL_CERTIFICATE_ID = "certificate_id"
|
66 |
|
|
COL_USAGE_TYPE_ID = "usage_type_id"
|
67 |
c073a0fc
|
Jan Pašek
|
|
68 |
|
|
# configuration default
|
69 |
|
|
DEFAULT_CONNECTION_STRING = "db/database_sqlite.db"
|
70 |
a766e644
|
Jan Pašek
|
DEFAULT_SERVER_BASE_URL = "http://localhost"
|
71 |
d78aa613
|
Jan Pašek
|
DEFAULT_LOG_LEVEL = "DEBUG"
|
72 |
a766e644
|
Jan Pašek
|
|
73 |
|
|
# available certificate states and revocation reasons
|
74 |
|
|
CERTIFICATE_STATES = {"valid", "revoked"}
|
75 |
|
|
CERTIFICATE_REVOCATION_REASONS = {"unspecified", "keyCompromise",
|
76 |
94e89bb1
|
Jan Pašek
|
"CACompromise", "affiliationChanged",
|
77 |
a766e644
|
Jan Pašek
|
"superseded", "cessationOfOperation",
|
78 |
94e89bb1
|
Jan Pašek
|
"certificateHold", "removeFromCRL"}
|
79 |
94f8d5cf
|
Jan Pašek
|
CERTIFICATE_REVOCATION_REASON_HOLD = "certificateHold"
|
80 |
64cfca84
|
Jan Pašek
|
|
81 |
4beb92c2
|
Jan Pašek
|
CERTIFICATE_VALID = "valid"
|
82 |
|
|
CERTIFICATE_REVOKED = "revoked"
|
83 |
|
|
CERTIFICATE_EXPIRED = "expired"
|
84 |
|
|
|
85 |
64cfca84
|
Jan Pašek
|
|
86 |
|
|
# Insert values into the template using % (index_file, serial_file)
|
87 |
|
|
CRL_CONFIG = """[ ca ]
|
88 |
|
|
default_ca = crl_ca
|
89 |
|
|
|
90 |
|
|
[ crl_ext ]
|
91 |
|
|
authorityKeyIdentifier=keyid:always
|
92 |
|
|
|
93 |
|
|
[ crl_ca ]
|
94 |
|
|
database = %s
|
95 |
|
|
serial = %s
|
96 |
|
|
default_md = sha1
|
97 |
dd91fb7a
|
Jan Pašek
|
policy = crl_policy
|
98 |
64cfca84
|
Jan Pašek
|
default_crl_days = 30
|
99 |
|
|
|
100 |
dd91fb7a
|
Jan Pašek
|
[ crl_policy ]
|
101 |
64cfca84
|
Jan Pašek
|
commonName = supplied
|
102 |
|
|
stateOrProvinceName = optional
|
103 |
|
|
countryName = optional
|
104 |
|
|
emailAddress = optional
|
105 |
|
|
organizationName = optional
|
106 |
|
|
organizationalUnitName = optional
|
107 |
|
|
|
108 |
|
|
"""
|