Project

General

Profile

DB Design » History » Version 6

Felix Tiede, 12/26/2011 08:30 AM
View and table match for extensions.

1 1 Felix Tiede
h1. Database structure
2
3 4 Felix Tiede
{{>toc}}
4 1 Felix Tiede
5 6 Felix Tiede
*Reflects database design from source:doc/db-schema.txt@a42b9563 of branch MVC (source:/?rev=MVC) now!*
6 1 Felix Tiede
7 6 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.
8 5 Felix Tiede
9 6 Felix Tiede
In any case source:doc/db-schema.txt is authoritative. This wiki page is only 
10
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 6 Felix Tiede
h2(#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
|@id@|Int (Auto-Increment, Unique)|Unique CA ID|
34 2 Felix Tiede
|@hash@|Long Int Unique|Hash of CA subject, used for identification throughout application|
35 6 Felix Tiede
|@parent@|Foreign Key (@authorities.hash@)|Subject hash of issuing CA, used to 
36
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 5 Felix Tiede
|@crldays@|Int|Validity timespan of issued CRLs|
43 6 Felix Tiede
|@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
The following indexes are used:
47 2 Felix Tiede
|@UNIQUE (id)@|
48 3 Felix Tiede
|@UNIQUE (keyid)@|
49
|@INDEX (parent)@|
50 1 Felix Tiede
|@INDEX (name ASC)@|
51
52
h2. Policies
53
54 6 Felix Tiede
Contains all policies to use at request signing to simplify authority configuration. Allows for just 
55
selecting another name instead of setting all values.
56 3 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.
57 2 Felix Tiede
58
Table name: @Policies@
59
|*Name*|*Type*|*Comment*|
60 1 Felix Tiede
|@id@|Int (Auto-Increment, Unique)|Unique policy ID|
61 6 Felix Tiede
|@name@|Varchar (Unique)|Friendly name for display in authority configuration|
62 5 Felix Tiede
|@Country@|Enum(match, supplied, optional)||
63 2 Felix Tiede
|@STate@|Enum(match, supplied, optional)||
64
|@Location@|Enum(match, supplied, optional)||
65
|@Organization@|Enum(match, supplied, optional)||
66 1 Felix Tiede
|@OrganizationalUnit@|Enum(match, supplied, optional)||
67
|@CommonName@|Enum(match, supplied, optional)||
68 2 Felix Tiede
|@Email@|Enum(match, supplied, optional)|Relates to subject key '@emailAddress@'|
69 1 Felix Tiede
70
The following indexes are used:
71 6 Felix Tiede
r
72 2 Felix Tiede
|@UNIQUE (id)@|
73
|@UNIQUE (name)@|
74 1 Felix Tiede
|@UNIQUE (Country, STate, Location, Organization, OrganizationalUnit, CommonName, Email)@|
75
|@INDEX (name ASC)@|
76
77
h2. Extensions
78 2 Felix Tiede
79
Extensions are added to certificates and CRLs on creation by a certification authority. This table contains all available extensions in use.
80
81
Table name: @Extensions@
82 4 Felix Tiede
|*Name*|*Type*|*Comment*|
83 5 Felix Tiede
|@id@|Long Int (Auto-Increment, Unique)|Unique extension ID|
84 4 Felix Tiede
|@type@|Enum(cert, crl)|Whether an extension is to be used for certificates or CRLs|
85 5 Felix Tiede
|@critical@|Bool|
86 6 Felix Tiede
|@oid@|Varchar|Numerical object ID of extension|
87 1 Felix Tiede
|@value@|Varchar|Text value of extension|
88
89 2 Felix Tiede
The following indexes are used:
90 1 Felix Tiede
|@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
98 2 Felix Tiede
Table name: @CAExtensions@
99 1 Felix Tiede
|*Name*|*Type*|*Comment*|
100 6 Felix Tiede
|@id@|Long Int (
101
Auto-Increment, Unique)|Unique connection ID|
102 1 Felix Tiede
|@authority@|Foreign Key (@authorities.id@)|ID of [[DB_Design#Authorities|authority]] to connect to an extension|
103
|@extension@|Foreign Key (@extensions.id@)|ID of [[DB_Design#Extensions|extension]] to connect to an authority|
104
105
The following indexes are used:
106
|@UNIQUE (id)@|
107
|@UNIQUE (authority, extension)@|
108
|@INDEX (authority)@|
109
|@INDEX (extension)@|
110
111
For faster access a view is also added which combines this @CAExtensions@ with @Extensions@ table:
112 5 Felix Tiede
113
View name: @AuthorityExtensions@
114 6 Felix Tiede
|*Name*|*Source field*|
115 5 Felix Tiede
|@authority@|@CAExtensions.authority@|
116
|@id@|@Extensions.id@|
117
|@type@|@Extensions.type@|
118
|@critical@|@Extensions.critical@|
119 6 Felix Tiede
|@oid@|@Extensions.oid@|
120 1 Felix Tiede
|@value@|@Extensions.value@|
121 5 Felix Tiede
122
SQL SELECT statement from which the view is populated:
123
<pre><code class="sql">
124 1 Felix Tiede
SELECT CAExtensions.authority AS authority, Extensions.id AS id, type, oid, critical, value
125 6 Felix Tiede
  FROM Extensions LEFT JOIN CAExtensions 
126
ON Extensions.id = CAExtensions.extension
127 5 Felix Tiede
</code></pre>
128
129 4 Felix Tiede
h2. Certificates
130 1 Felix Tiede
131 5 Felix Tiede
Stores every certificate issued by a managed certification authority and additional information.
132 2 Felix Tiede
133
Table name: @Certificates@
134
|*Name*|*Type*|*Comment*|
135
|@id@|Long Int (Auto-Increment, Unique)|Unique certificate ID|
136 1 Felix Tiede
|@serial@|Unsigned Long Long Int|64 bit serial number of certificate|
137 2 Felix Tiede
|@authority@|Foreign Key (@authorities.hash@)|Subject hash of [[DB_Design#Authorities|authority]] which issued the certificate|
138 5 Felix Tiede
|@subject@|Varchar|Certificate subject|
139 6 Felix Tiede
|@issued@|Datetime|Timestamp when certificate was issued, not necessarily identical to @validfrom@|
140 1 Felix Tiede
|@validfrom@|Datetime|Timestamp when certificate becomes valid, can not be before @issued@|
141 2 Felix Tiede
|@expiration@|Datetime|Timestamp when certificate becomes expired, can not be before @validfrom@|
142 3 Felix Tiede
|@owner@|Varchar|Owner identifier from Akonadi to connect certificate with an Akonadi contact|
143
|@status@|Enum(valid, expired, revoked)|
144 6 Felix Tiede
|@revocation@
145
|Datetime|Timestamp of revocation of certificate, can not be before @issued@ or after @expiration@|
146 5 Felix Tiede
|@reason@|Short Int|Reason of revocation|
147 4 Felix Tiede
|@certificate@|Blob|DER-encoded raw certificate data for documentary purposes and later re-export if needed|
148 2 Felix Tiede
149
The following indexes are used:
150
|@UNIQUE (id)@|
151
|@UNIQUE (authority, serial)@|
152
|@INDEX (authority)@|
153 1 Felix Tiede
|@INDEX (status ASC, id)@|
154 3 Felix Tiede
|@INDEX (status ASC, expiration ASC)@|
155 1 Felix Tiede
156 2 Felix Tiede
h2. Triggers
157 5 Felix Tiede
158 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.