2483
2483
serial-lock serial-lock-timeout-seconds] :as ca-settings} :- CaSettings
2484
2484
report-activity]
2485
2485
(let [; ; if part of a CA bundle, the intermediate CA will be first in the chain
2486
- cacert (utils/pem->ca-cert cacert cakey)
2486
+ cacert (utils/pem->ca-cert cacert cakey)
2487
2487
casubject (utils/get-subject-from-x509-certificate cacert)
2488
- ca-private-key (utils/pem->private-key cakey)]
2489
- ( when-not ( empty? subjects)
2490
- ; ; since we are going to be manipulating the serial file and the inventory file for multiple entries,
2491
- ; ; acquire the locks to prevent lock thrashing
2492
- (common/with-safe-write-lock serial-lock serial-lock-descriptor serial-lock-timeout-seconds
2493
- (common/with-safe-write-lock inventory-lock inventory-lock-descriptor inventory-lock-timeout-seconds
2494
- (let [results
2495
- ; ; loop through the subjects, one at a time, and collect the results for success or failure.
2496
- (loop [s subjects
2497
- result {:signed []
2498
- :no-csr []
2499
- :signing-errors[]}]
2500
- (if-not (empty? s)
2501
- (let [subject (first s)
2502
- csr-path (path-to-cert-request csrdir subject)]
2503
- (if (fs/exists? csr-path)
2504
- (let [_ (log/trace (i18n/trs " File exists at {0}" csr-path))
2505
- one-result (maybe-sign-one subject csr-path cacert casubject ca-private-key ca-settings)]
2506
- ; ; one-result is either :signed or :signing-errors
2507
- (recur (rest s)
2508
- (update result one-result conj subject)))
2509
- (do
2510
- (log/trace (i18n/trs " File does not exist at {0}" csr-path))
2511
- (recur (rest s)
2512
- (update result :no-csr conj subject)))))
2513
- result))]
2514
- ; ; submit the signing activity as one entry for all the hosts.
2515
- (when-not (empty? (:signed results))
2516
- (report-activity (:signed results) " signed" ) )
2517
- results) )))))
2488
+ ca-private-key (utils/pem->private-key cakey)]
2489
+
2490
+ ; ; since we are going to be manipulating the serial file and the inventory file for multiple entries,
2491
+ ; ; acquire the locks to prevent lock thrashing
2492
+ (common/with-safe-write-lock serial-lock serial-lock-descriptor serial-lock-timeout-seconds
2493
+ (common/with-safe-write-lock inventory-lock inventory-lock-descriptor inventory-lock-timeout-seconds
2494
+ (let [results
2495
+ ; ; loop through the subjects, one at a time, and collect the results for success or failure.
2496
+ (loop [s subjects
2497
+ result {:signed []
2498
+ :no-csr []
2499
+ :signing-errors []}]
2500
+ (if-not (empty? s)
2501
+ (let [subject (first s)
2502
+ csr-path (path-to-cert-request csrdir subject)]
2503
+ (if (fs/exists? csr-path)
2504
+ (let [_ (log/trace (i18n/trs " File exists at {0}" csr-path))
2505
+ one-result (maybe-sign-one subject csr-path cacert casubject ca-private-key ca-settings)]
2506
+ ; ; one-result is either :signed or :signing-errors
2507
+ (recur (rest s)
2508
+ (update result one-result conj subject)))
2509
+ (do
2510
+ (log/trace (i18n/trs " File does not exist at {0}" csr-path))
2511
+ (recur (rest s)
2512
+ (update result :no-csr conj subject)))))
2513
+ result))]
2514
+ ; ; submit the signing activity as one entry for all the hosts.
2515
+ (when-not (empty? (:signed results) ))
2516
+ (report-activity (:signed results) " signed" )
2517
+ results)))))
0 commit comments