   (let [keypair (utils/generate-key-pair keylength)
         public-key (utils/get-public-key keypair)
         private-key (utils/get-private-key keypair)]
-    (utils/key->pem! public-key hostpubkey)
-    (utils/key->pem! private-key
-                     (create-file-with-perms hostprivkey
-                                             private-key-perms))
+    (write-public-key public-key hostpubkey)
+    (write-private-key private-key hostprivkey)
     public-key))
 
 (schema/defn generate-master-ssl-keys! :- (schema/pred utils/public-key?)

  (mapv (partial str "DNS:")
        (utils/get-subject-dns-alt-names cert-or-csr)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Serial number functions + lock

(def serial-file-lock
  "The lock used to prevent concurrent access to the serial number file."
  (new Object))

(schema/defn parse-serial-number :- schema/Int
  "Parses a serial number from its format on disk.  See `format-serial-number`

        serial-count (count serials)
        new-crl (utils/revoke-multiple original-crl ca-private-key
                                       ca-public-key serials)]
    (write-crl new-crl cacrl)
    (log/debug (if (= 1 serial-count)
                 (i18n/trs "Revoked 1 certificate.")
                 (i18n/trs "Revoked {0} certificates." serial-count)))))
