| 1 | #! /usr/bin/tclsh |
| 2 | ### -*-tcl-*- |
| 3 | ### |
| 4 | ### Revoke a certificate request |
| 5 | ### |
| 6 | ### (c) 2011 Mark Wooding |
| 7 | ### |
| 8 | |
| 9 | ###----- Licensing notice --------------------------------------------------- |
| 10 | ### |
| 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 |
| 14 | ### (at your option) any later version. |
| 15 | ### |
| 16 | ### This program is distributed in the hope that it will be useful, |
| 17 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | ### GNU General Public License for more details. |
| 20 | ### |
| 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 Foundation, |
| 23 | ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 24 | |
| 25 | ## Find the common utilities. |
| 26 | source [file join [file dirname $argv0] "../lib/func.tcl"] |
| 27 | |
| 28 | ## Open the database |
| 29 | sqlite3 db "$CERTROOT/state/ca.db" |
| 30 | db nullvalue nil |
| 31 | cd "$CERTROOT" |
| 32 | |
| 33 | ## Establish the right parameters to store. |
| 34 | set usage "usage: $argv0 REQUEST REASON \[DETAIL ...\]" |
| 35 | if {$argc < 2} { |
| 36 | puts stderr $usage |
| 37 | exit 1 |
| 38 | } |
| 39 | lassign $argv reqid reason |
| 40 | revoke-reason-info $reason R |
| 41 | set detail [revoke-parse-detail R [lrange $argv 2 end]] |
| 42 | |
| 43 | ## Do the revocation. |
| 44 | db transaction { |
| 45 | revoke-requests R $detail [request-match $reqid "st != 'expired'"] |
| 46 | } |
| 47 | |
| 48 | ###----- That's all, folks -------------------------------------------------- |