Skip to content

Commit

Permalink
Trigger challenges when authorization is pending
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsz committed Mar 20, 2018
1 parent 98324aa commit 846b6d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/certificaat/interface/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/certificaat/kung_fu.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit 846b6d1

Please sign in to comment.