4 ### Generate a new root key
6 ### (c) 2022 Mark Wooding
9 ###----- Licensing notice ---------------------------------------------------
11 ### This program is free software: you can redistribute it and/or modify
12 ### it under the terms of the GNU General Public License as published by
13 ### the Free Software Foundation; either version 2 of the License, or (at
14 ### your option) any later version.
16 ### This program is distributed in the hope that it will be useful, but
17 ### WITHOUT ANY WARRANTY; without even the implied warranty of
18 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ### General Public License for more details.
21 ### You should have received a copy of the GNU General Public License
22 ### along with this program. If not, write to the Free Software
23 ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 ## Find the common utilities.
27 source [file join [file dirname $argv0] "../lib/func.tcl"]
30 sqlite3 db "$CERTROOT/state/ca.db"
34 ## Refresh the database's idea of request profiles.
37 ## Rename the old CA key so we don't lose it.
39 while {[file exists private/ca-$i.key]} { set i [expr {$i + 1}] }
40 file rename private/ca.key private/ca-$i.key
41 file rename ca.cert ca-$i.cert
46 ## Generate new certificates for all of the live requests.
48 foreach id [db eval { SELECT id FROM request WHERE st = 'active' }] {
52 ## Update OpenSSL's database of things.
53 exec openssl ca -config "etc/openssl.conf" -updatedb 2>@1
56 exec openssl ca -config "etc/openssl.conf" -gencrl | \
57 openssl crl -text -out "crl" 2>@1
59 ## Call the user hook.
62 ###----- That's all, folks --------------------------------------------------