--sign-file signs a single CSR from command line then exits

This commit is contained in:
Daniel Barlow 2024-10-04 23:07:48 +01:00
parent f3960c6b76
commit c4ea32ab1e
1 changed files with 18 additions and 4 deletions

View File

@ -65,6 +65,8 @@
(assoc (parse-args rest) :server-private-key (slurp f))
["--challenge-password" f & rest]
(assoc (parse-args rest) :challenge-password (read-line f))
["--sign-file" f & rest]
(assoc (parse-args rest) :sign-and-exit (slurp f))
[bind-address] { : bind-address }
_ {}))
@ -72,6 +74,8 @@
(doto
(parse-args arg)
(case
{:sign-and-exit pathname }
true
{: ca-certificate : ca-private-key
: server-certificate : server-private-key
: challenge-password : bind-address}
@ -141,7 +145,17 @@
:ctx (ssl-context)
}))))
(let [s (new-server)]
(ncall (s:listen))
(print "server ready")
(ncall (s:loop)))
(fn run-server []
(let [s (new-server)]
(ncall (s:listen))
(print "server ready")
(ncall (s:loop))))
(fn sign-text [s]
(let [crt (new-crt (csr.new s))]
(print (crt:toPEM))))
(if options.sign-and-exit
(sign-text options.sign-and-exit)
(run-server))