Skip to content

Commit

Permalink
CP-46804: Add function to get master's external certificate thumbprint
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Woods <[email protected]>
  • Loading branch information
snwoods committed Jan 8, 2024
1 parent 53d2e8c commit 32707b8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ocaml/xapi/helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,31 @@ let update_ca_bundle =
)
)

let external_certificate_thumbprint_of_master ?(hash_type = `Sha256) () =
match hash_type with
| `Sha256 ->
Server_helpers.exec_with_new_task
"Get master's external certificate thumbprint" (fun __context ->
let master_ref = get_master ~__context in
let certs =
Db.Certificate.get_records_where ~__context
~expr:
(And
( Eq (Field "host", Literal (Ref.string_of master_ref))
, Eq (Field "type", Literal "host")
)
)
in
match certs with
| [] ->
debug "Failed to fetch master's external certificate" ;
None
| (_, cert_record) :: _ ->
Some cert_record.certificate_fingerprint
)
| _ ->
None

let unit_test ~__context : bool =
Pool_role.is_unit_test ()
||
Expand Down

0 comments on commit 32707b8

Please sign in to comment.