Almost a complete rewrite.
[ca] / bin / revoke
diff --git a/bin/revoke b/bin/revoke
new file mode 100755 (executable)
index 0000000..15ae900
--- /dev/null
@@ -0,0 +1,48 @@
+#! /usr/bin/tclsh8.5
+### -*-tcl-*-
+###
+### Revoke a certificate request
+###
+### (c) 2011 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This program is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+###
+### This program is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with this program; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## Find the common utilities.
+source [file join [file dirname $argv0] "../lib/func.tcl"]
+
+## Open the database
+sqlite3 db "$CERTROOT/state/ca.db"
+db nullvalue nil
+cd "$CERTROOT"
+
+## Establish the right parameters to store.
+set usage "usage: $argv0 REQUEST REASON \[DETAIL ...\]"
+if {$argc < 2} {
+  puts stderr $usage
+  exit 1
+}
+lassign $argv reqid reason
+revoke-reason-info $reason R
+set detail [revoke-parse-detail R [lrange $argv 2 end]]
+
+## Do the revocation.
+db transaction {
+  revoke-requests R $detail [request-match $reqid "st != 'expired'"]
+}
+
+###----- That's all, folks --------------------------------------------------