package albatross
Albatross - orchestrate and manage MirageOS unikernels with Solo5
Install
Dune Dependency
Authors
Maintainers
Sources
albatross-1.4.3.tbz
sha256=fd235fedabdbc7b7523bfc3afab2b878dd862314b52fcc80604076a2cff9eb2b
sha512=86939f0e444f49ed52398efeef8d5382a66b8529d084c22b83cd5c2bc860b2df0d9827093f96ed9bde4d586694dd758d9fb0e6800aedcd761f244c55a6a549f3
doc/src/albatross.tls/vmm_tls.ml.html
Source file vmm_tls.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
(* (c) 2018 Hannes Mehnert, all rights reserved *) open X509 let ( let* ) = Result.bind (* we skip all non-albatross certificates *) let cert_name cert = match Extension.(find (Unsupported Vmm_asn.oid) (Certificate.extensions cert)) with | None -> Ok None | Some (_, data) -> match X509.(Distinguished_name.common_name (Certificate.subject cert)) with | Some name -> Ok (Some name) | None -> match Vmm_asn.of_cert_extension data with | Error (`Msg _) -> Error (`Msg "couldn't parse albatross extension") | Ok (_, `Policy_cmd pc) -> begin match pc with | `Policy_add _ -> Error (`Msg "policy add may not have an empty name") | `Policy_remove -> Error (`Msg "policy remove may not have an empty name") | `Policy_info -> Ok None end | Ok (_, `Block_cmd bc) -> begin match bc with | `Block_add _ -> Error (`Msg "block add may not have an empty name") | `Block_remove -> Error (`Msg "block remove may not have an empty name") | `Block_set _ -> Error (`Msg "block set may not have an empty name") | `Block_dump _ -> Error (`Msg "block dump may not have an empty name") | `Block_info -> Ok None end | _ -> Ok None let name chain = List.fold_left (fun acc cert -> match acc, cert_name cert with | Error e, _ -> Error e | _, Error e -> Error e | Ok acc, Ok None -> Ok acc | Ok acc, Ok (Some data) -> Vmm_core.Name.append data acc) (Ok Vmm_core.Name.root) chain (* this separates the leaf and top-level certificate from the chain, and also reverses the intermediates (to be (leaf, CA -> subCA -> subCA') in which subCA' signed leaf *) let separate_chain = function | [] -> Error (`Msg "empty chain") | [ leaf ] -> Ok (leaf, []) | leaf :: xs -> Ok (leaf, List.rev xs) let wire_command_of_cert cert = match Extension.(find (Unsupported Vmm_asn.oid) (Certificate.extensions cert)) with | None -> Error `Not_present | Some (_, data) -> let* v, wire = Vmm_asn.of_cert_extension data in if not Vmm_commands.(is_current v) then Logs.warn (fun m -> m "version mismatch, received %a current %a" Vmm_commands.pp_version v Vmm_commands.pp_version Vmm_commands.current); Ok (v, wire) let extract_policies chain = List.fold_left (fun acc cert -> match acc, wire_command_of_cert cert with | Error e, _ -> Error e | Ok acc, Error `Not_present -> Ok acc | Ok _, Error (`Msg msg) -> Error (`Msg msg) | Ok (prefix, acc), Ok (_, `Policy_cmd `Policy_add p) -> let* name = let* cn = cert_name cert in match cn with | None -> Ok prefix | Some x -> Vmm_core.Name.prepend x prefix in Ok (name, (name, p) :: acc) | _, Ok wire -> Error (`Msg (Fmt.str "unexpected wire %a" (Vmm_commands.pp ~verbose:false) (snd wire)))) (Ok (Vmm_core.Name.root, [])) chain let handle chain = let* () = if List.length chain < 10 then Ok () else Error (`Msg "certificate chain too long") in let* leaf, rest = separate_chain chain in (* use subject common names of intermediate certs as prefix *) let* name' = name rest in (* and subject common name of leaf certificate -- allowing dots in CN -- as postfix *) let* name = let* cn = cert_name leaf in match cn with | None | Some "." -> Ok name' | Some x -> let* post = Vmm_core.Name.of_string x in Ok (Vmm_core.Name.concat name' post) in Logs.debug (fun m -> m "name is %a leaf is %a, chain %a" Vmm_core.Name.pp name Certificate.pp leaf Fmt.(list ~sep:(any " -> ") Certificate.pp) rest); let* _, policies = extract_policies rest in (* TODO: logging let login_hdr, login_ev = Log.hdr name, `Login addr in *) match wire_command_of_cert leaf with | Error `Msg p -> Error (`Msg p) | Error `Not_present -> Error (`Msg "leaf certificate does not contain an albatross extension") | Ok (v, wire) -> (* we only allow some commands via certificate *) match wire with | `Console_cmd (`Console_subscribe _) | `Stats_cmd `Stats_subscribe | `Unikernel_cmd _ | `Policy_cmd `Policy_info | `Block_cmd _ -> Ok (name, policies, v, wire) | _ -> Error (`Msg "unexpected command")
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>