Project

General

Profile

DB Design » History » Version 4

Felix Tiede, 12/11/2011 08:12 PM
Reflect database changes from commit:9bbb6749f5b7c50abb3306b75760c9afe3cfeebd.

1 1 Felix Tiede
h1. Database structure
2
3 4 Felix Tiede
{{>toc}}
4 1 Felix Tiede
5
*Reflects database design from source:doc/db-schema.txt@cef9a866 of branch MVC (source:/?rev=MVC) now!*
6 3 Felix Tiede
7 4 Felix Tiede
kCA relies on a SQL 
8
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 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 3 Felix Tiede
|@value@|Varchar|Stored value|
24 1 Felix Tiede
25 4 Felix Tiede
Currently this table is used solely for the purpose of preventing damage to the database by mismatch 
26
between application and database structure.
27 1 Felix Tiede
28
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 4 Felix Tiede
|@hash@|Long Int Unique|Hash of CA subject, used for identification throughout application|
36
|@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
|@digest@|Int|Digest used in all signing operations performed by authority|
39 3 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 4 Felix Tiede
|@crlnumber@|Int|Number of last issued CRL, incremented each time a CRL is issued|
42 3 Felix Tiede
|@crldays@|Int|Validity timespan of issued CRLs|
43 4 Felix Tiede
n|@certificate@|Blob|DER-encoded raw data of 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 4 Felix Tiede
|@name@|Varchar (
61
Unique)|Friendly name for display in authority 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
|@type@|Enum(cert, crl)|Whether an extension is to be used for 
84
certificates or CRLs|
85 2 Felix Tiede
|@critical@|Bool|
86 1 Felix Tiede
|@oid@|Varchar|Numerical object ID of extension|
87
|@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
Table name: @CAExtensions@
99
|*Name*|*Type*|*Comment*|
100 1 Felix Tiede
|@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 4 Felix Tiede
|@INDEX (authority)@|
108 1 Felix Tiede
|@INDEX (extension)@|
109
110 3 Felix Tiede
h2. Certificates
111 1 Felix Tiede
112 4 Felix Tiede
Stores every certificate issued by a managed certification 
113
authority and additional information.
114 2 Felix Tiede
115
Table name: @Certificates@
116
|*Name*|*Type*|*Comment*|
117
|@id@|Long Int (Auto-Increment, Unique)|Unique certificate ID|
118
|@serial@|Unsigned Long Long Int|64 bit serial number of certificate|
119 4 Felix Tiede
|@authority@|Foreign Key (@authorities.hash@)|Subject hash of [[DB_Design#Authorities|authority]] which issued the certificate|
120 2 Felix Tiede
|@subject@|Varchar|Certificate subject|
121
|@issued@|Datetime|Timestamp when certificate was issued, not necessarily identical to @validfrom@|
122
|@validfrom@|Datetime|Timestamp when certificate becomes valid, can not be before @issued@|
123
|@expiration@|Datetime|Timestamp when certificate becomes expired, can not be before @validfrom@|
124 3 Felix Tiede
|@owner@|Varchar|Owner identifier from Akonadi to connect certificate with an Akonadi contact|
125
|@status@|Enum(valid, expired, revoked)|
126 4 Felix Tiede
|@revocation@|Datetime|Timestamp of revocation of certificate, can not be before @issued@ or after @expiration@|
127 3 Felix Tiede
|@reason@|Short Int|Reason of revocation|
128 4 Felix Tiede
|@
129
certificate@|Blob|DER-encoded raw certificate data for documentary purposes and later re-export if needed|
130 2 Felix Tiede
131
The following indexes are used:
132
|@UNIQUE (id)@|
133
|@UNIQUE (authority, serial)@|
134
|@INDEX (authority)@|
135 1 Felix Tiede
|@INDEX (status ASC, id)@|
136 3 Felix Tiede
|@INDEX (status ASC, expiration ASC)@|
137 1 Felix Tiede
138 2 Felix Tiede
h2. Triggers
139 1 Felix Tiede
140
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.