Project

General

Profile

DB Design » History » Version 7

Felix Tiede, 12/29/2011 01:28 PM
Path flag added to @Authorities@ table, see #23.

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