diff --git a/src/certificaat/interface/cli.clj b/src/certificaat/interface/cli.clj index 8cfee59..0761800 100644 --- a/src/certificaat/interface/cli.clj +++ b/src/certificaat/interface/cli.clj @@ -119,9 +119,10 @@ (not (k/valid? (str config-dir "registration.uri") options)) (register options) (not (k/valid? (str config-dir domain "/authorization." domain ".uri") options)) (do (authorize options) (h/run-hooks :before-challenge options)) - (not (k/valid? (str config-dir domain "/certificate.uri") options)) (do (accept-challenges options) - (request options) - (h/run-hooks :after-request options)) + (or (k/pending? (str config-dir domain "/authorization." domain ".uri") options) + (not (k/valid? (str config-dir domain "/certificate.uri") options))) (do (accept-challenges options) + (request options) + (h/run-hooks :after-request options)) :else (exit 0 "Nothing left to do at this point in time."))) (defn renew [{domain :domain config-dir :config-dir :as options}] (if (k/valid? (str config-dir domain "/authorization." domain ".uri") options) diff --git a/src/certificaat/kung_fu.clj b/src/certificaat/kung_fu.clj index 11c7734..70cfdf6 100644 --- a/src/certificaat/kung_fu.clj +++ b/src/certificaat/kung_fu.clj @@ -68,6 +68,11 @@ challenge (challenge/restore session uri)]] (challenge/accept challenge)))) +(defn pending? [frozen-resource options] + (let [authorization-uri (c/load-uri frozen-resource) + authorization (authorization/restore session authorization-uri)] + (= Status/PENDING (.getStatus authorization)))) + (defn get-certificate [{:keys [config-dir domain organisation san] :as options} reg] (let [path (str config-dir domain "/") csr (str path "request.csr")]