Skip to content

Commit

Permalink
[xcpng] fix pem fingerprint startup
Browse files Browse the repository at this point in the history
  • Loading branch information
gthvn1 committed Feb 10, 2025
1 parent 718bd1e commit 458b7b7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions ocaml/xapi/certificates.ml
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,21 @@ end = struct
(fun (self, record) ->
let read_fingerprints filename =
let ( let* ) = Result.bind in
let* certificate =
Xapi_stdext_unix.Unixext.string_of_file filename
|> Cstruct.of_string
|> X509.Certificate.decode_pem
in
let sha1 = pp_fingerprint ~hash_type:`SHA1 certificate in
let sha256 = pp_fingerprint ~hash_type:`SHA256 certificate in
Ok (sha1, sha256)
try
let* certificate =
Xapi_stdext_unix.Unixext.string_of_file filename
|> Cstruct.of_string
|> X509.Certificate.decode_pem
in
let sha1 = pp_fingerprint ~hash_type:`SHA1 certificate in
let sha256 = pp_fingerprint ~hash_type:`SHA256 certificate in
Ok (sha1, sha256)
with
| Unix.Unix_error (Unix.ENOENT, _, _) ->
Error
(`Msg (Printf.sprintf "filename %s does not exist" filename))
| exn ->
Error (`Msg (Printexc.to_string exn))
in
let filename =
Filename.concat
Expand Down

0 comments on commit 458b7b7

Please sign in to comment.