DB Design » History » Version 5
Felix Tiede, 12/24/2011 06:55 AM
Integrated new view for an authority's extensions
1 | 1 | Felix Tiede | h1. Database structure |
---|---|---|---|
2 | |||
3 | 4 | Felix Tiede | {{>toc}} |
4 | 1 | Felix Tiede | |
5 | 5 | Felix Tiede | *Reflects database design from source:doc/db-schema.txt@6a552297 of branch MVC (source:/?rev=MVC) now!* |
6 | 3 | Felix Tiede | |
7 | 5 | Felix Tiede | kCA relies on a SQL database backend to store information on known |
8 | certification authorities, issued certificates and some settings. It is the responsibility of the user to make sure database access rights are only granted to those allowed to perform certain operations. kCA authorizes some operations by asking for an authority's key, but if the user has the key, he is able to do any operation, whether he should or not. |
||
9 | 1 | Felix Tiede | |
10 | 2 | Felix Tiede | In any case source:doc/db-schema.txt is authoritative. This wiki page is only for additional documentation purposes. |
11 | 1 | Felix Tiede | |
12 | *Currently only SQLite backend is supported!* |
||
13 | |||
14 | Following are the table structures required by kCA. |
||
15 | |||
16 | h2. Settings |
||
17 | |||
18 | Contains information general information which is not associated with any other information in the database. |
||
19 | 2 | Felix Tiede | |
20 | 1 | Felix Tiede | Table name: @Settings@ |
21 | |*Name*|*Type*|*Comment*| |
||
22 | |@name@|Varchar|Name of stored setting| |
||
23 | |@value@|Varchar|Stored value| |
||
24 | 4 | Felix Tiede | |
25 | 5 | Felix Tiede | Currently this table is used solely for the purpose of preventing damage to the database by mismatch between application and database structure. |
26 | 1 | Felix Tiede | |
27 | 5 | Felix Tiede | nh2(#Authorities). Certification Authorities |
28 | 2 | Felix Tiede | |
29 | 1 | Felix Tiede | Contains main information about certification authorities, basically the heart of the application. |
30 | |||
31 | Table name: @Authorities@ |
||
32 | |*Name*|*Type*|*Comment*| |
||
33 | 2 | Felix Tiede | |@id@|Int (Auto-Increment, Unique)|Unique CA ID| |
34 | 4 | Felix Tiede | |@hash@|Long Int Unique|Hash of CA subject, used for identification throughout application| |
35 | |@parent@|Foreign Key (@authorities.hash@)|Subject hash of issuing CA, used to build authority tree| |
||
36 | 1 | Felix Tiede | |@name@|Varchar|Friendly name for display in GUI, also reported via D-Bus property @authorities@| |
37 | |@digest@|Int|Digest used in all signing operations performed by authority| |
||
38 | |@certificatedays@|Int|Default validity timespan of new certificates in days| |
||
39 | 3 | Felix Tiede | |@policy@|Foreign Key (@policies.id@)|Id of [[DB_Design#Policies|policy]] to use while signing requests| |
40 | |@crlnumber@|Int|Number of last issued CRL, incremented each time a CRL is issued| |
||
41 | 4 | Felix Tiede | |@crldays@|Int|Validity timespan of issued CRLs| |
42 | 5 | Felix Tiede | |@certificate@|Blob|DER-encoded raw data of |
43 | authority certificate, used in every signing operation| |
||
44 | 1 | Felix Tiede | |@key@|Blob|Filename to authority's private key or PEM-encoded raw data of authority's private key, possibly passphrase protected| |
45 | |||
46 | 2 | Felix Tiede | The following indexes are used: |
47 | 3 | Felix Tiede | |@UNIQUE (id)@| |
48 | |@UNIQUE (keyid)@| |
||
49 | 1 | Felix Tiede | |@INDEX (parent)@| |
50 | |@INDEX (name ASC)@| |
||
51 | |||
52 | h2. Policies |
||
53 | |||
54 | Contains all policies to use at request signing to simplify authority configuration. Allows for just selecting another name instead of setting all values. |
||
55 | 2 | Felix Tiede | A policy decides whether a specific part of a request's subject must match the related part of the signing authority's subject to allow signing, must be just supplied (allows for any value except blank) or is entirely optional (allows also blank values). Capitalized letters of field names show the key of the subject part in question. |
56 | 3 | Felix Tiede | |
57 | 2 | Felix Tiede | Table name: @Policies@ |
58 | |*Name*|*Type*|*Comment*| |
||
59 | |@id@|Int (Auto-Increment, Unique)|Unique policy ID| |
||
60 | 5 | Felix Tiede | |@name@|Varchar (Unique)|Friendly name for display in authority |
61 | configuration| |
||
62 | 2 | Felix Tiede | |@Country@|Enum(match, supplied, optional)|| |
63 | |@STate@|Enum(match, supplied, optional)|| |
||
64 | |@Location@|Enum(match, supplied, optional)|| |
||
65 | 1 | Felix Tiede | |@Organization@|Enum(match, supplied, optional)|| |
66 | |@OrganizationalUnit@|Enum(match, supplied, optional)|| |
||
67 | 2 | Felix Tiede | |@CommonName@|Enum(match, supplied, optional)|| |
68 | 1 | Felix Tiede | |@Email@|Enum(match, supplied, optional)|Relates to subject key '@emailAddress@'| |
69 | |||
70 | 2 | Felix Tiede | The following indexes are used: |
71 | |@UNIQUE (id)@| |
||
72 | |@UNIQUE (name)@| |
||
73 | 1 | Felix Tiede | |@UNIQUE (Country, STate, Location, Organization, OrganizationalUnit, CommonName, Email)@| |
74 | |@INDEX (name ASC)@| |
||
75 | |||
76 | h2. Extensions |
||
77 | |||
78 | 2 | Felix Tiede | Extensions are added to certificates and CRLs on creation by a certification authority. This table contains all available extensions in use. |
79 | |||
80 | Table name: @Extensions@ |
||
81 | |*Name*|*Type*|*Comment*| |
||
82 | 4 | Felix Tiede | |@id@|Long Int (Auto-Increment, Unique)|Unique extension ID| |
83 | 5 | Felix Tiede | |@type@|Enum(cert, crl)|Whether an extension is to be used for certificates or CRLs| |
84 | 4 | Felix Tiede | |@critical@|Bool| |
85 | 5 | Felix Tiede | |@oid@ |
86 | |Varchar|Numerical object ID of extension| |
||
87 | 1 | Felix Tiede | |@value@|Varchar|Text value of extension| |
88 | 2 | Felix Tiede | |
89 | 1 | Felix Tiede | The following indexes are used: |
90 | |@UNIQUE (id)@| |
||
91 | |@UNIQUE (type, oid, value)@| |
||
92 | |@INDEX (oid)@| |
||
93 | |||
94 | h2(#CAExtensions). Authority Extensions |
||
95 | |||
96 | Connects extensions to authorities. Since one authority uses an arbitrary number of extensions, this table is needed. |
||
97 | 2 | Felix Tiede | |
98 | 1 | Felix Tiede | Table name: @CAExtensions@ |
99 | |*Name*|*Type*|*Comment*| |
||
100 | |@id@|Long Int (Auto-Increment, Unique)|Unique connection ID| |
||
101 | |@authority@|Foreign Key (@authorities.id@)|ID of [[DB_Design#Authorities|authority]] to connect to an extension| |
||
102 | |@extension@|Foreign Key (@extensions.id@)|ID of [[DB_Design#Extensions|extension]] to connect to an authority| |
||
103 | |||
104 | The following indexes are used: |
||
105 | |@UNIQUE (id)@| |
||
106 | |@UNIQUE (authority, extension)@| |
||
107 | |@INDEX (authority)@| |
||
108 | |@INDEX (extension)@| |
||
109 | |||
110 | 5 | Felix Tiede | For faster access a view is also added which combines this @CAExtensions@ with @Extensions@ table: |
111 | |||
112 | View name: @AuthorityExtensions@ |
||
113 | n|*Name*|*Source field*| |
||
114 | |@authority@|@CAExtensions.authority@| |
||
115 | |@id@|@Extensions.id@| |
||
116 | |@type@|@Extensions.type@| |
||
117 | |@oid@|@Extensions.oid@| |
||
118 | |@critical@|@Extensions.critical@| |
||
119 | |@value@|@Extensions.value@| |
||
120 | |||
121 | SQL SELECT statement from which the view is populated: |
||
122 | <pre><code class="sql"> |
||
123 | SELECT CAExtensions.authority AS authority, Extensions.id AS id, type, oid, critical, value |
||
124 | FROM Extensions LEFT JOIN CAExtensions ON Extensions.id = CAExtensions.extension |
||
125 | </code></pre> |
||
126 | |||
127 | 4 | Felix Tiede | h2. Certificates |
128 | 1 | Felix Tiede | |
129 | 5 | Felix Tiede | Stores every certificate issued by a managed certification authority and additional information. |
130 | 2 | Felix Tiede | |
131 | Table name: @Certificates@ |
||
132 | |*Name*|*Type*|*Comment*| |
||
133 | |@id@|Long Int (Auto-Increment, Unique)|Unique certificate ID| |
||
134 | 4 | Felix Tiede | |@serial@|Unsigned Long Long Int|64 bit serial number of certificate| |
135 | 2 | Felix Tiede | |@authority@|Foreign Key (@authorities.hash@)|Subject hash of [[DB_Design#Authorities|authority]] which issued the certificate| |
136 | |@subject@|Varchar|Certificate subject| |
||
137 | 5 | Felix Tiede | |@ |
138 | issued@|Datetime|Timestamp when certificate was issued, not necessarily identical to @validfrom@| |
||
139 | 1 | Felix Tiede | |@validfrom@|Datetime|Timestamp when certificate becomes valid, can not be before @issued@| |
140 | 2 | Felix Tiede | |@expiration@|Datetime|Timestamp when certificate becomes expired, can not be before @validfrom@| |
141 | 3 | Felix Tiede | |@owner@|Varchar|Owner identifier from Akonadi to connect certificate with an Akonadi contact| |
142 | |@status@|Enum(valid, expired, revoked)| |
||
143 | 4 | Felix Tiede | |@revocation@|Datetime|Timestamp of revocation of certificate, can not be before @issued@ or after @expiration@| |
144 | 3 | Felix Tiede | |@reason@|Short Int|Reason of revocation| |
145 | 5 | Felix Tiede | |@certificate@|Blob|DER-encoded raw certificate data for documentary purposes and later re-export if needed| |
146 | 4 | Felix Tiede | |
147 | 2 | Felix Tiede | The following indexes are used: |
148 | |@UNIQUE (id)@| |
||
149 | |@UNIQUE (authority, serial)@| |
||
150 | |@INDEX (authority)@| |
||
151 | |@INDEX (status ASC, id)@| |
||
152 | 1 | Felix Tiede | |@INDEX (status ASC, expiration ASC)@| |
153 | 3 | Felix Tiede | |
154 | 1 | Felix Tiede | h2. Triggers |
155 | 2 | Felix Tiede | |
156 | 5 | Felix Tiede | The database should - if somehow possible - auto-expire certificates. This should set a |
157 | certificate's @state@ to @expired@, if it is not revoked but the timestamp in @expiration@ is in the past. Only exception should be certificates revoked by @CertificateOnHold@, which should also be auto-expired. At best it should do so on any database operation. |