Skip to content

Commit

Permalink
Merge pull request #71 from mtelvers/pem-keys
Browse files Browse the repository at this point in the history
Keys have now been converted and sexplib completely removed
  • Loading branch information
mtelvers authored Mar 1, 2024
2 parents 52d209d + d634318 commit 9bec7f8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
10 changes: 4 additions & 6 deletions client/client.ml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
let parse_key key =
let key = IO.with_in (Fpath.to_string key) (IO.read_all ?size:None) in
let key =
try Mirage_crypto_pk.Rsa.priv_of_sexp (Sexplib.Sexp.of_string key) with
Sexplib0.Sexp_conv.Of_sexp_error _ ->
match X509.Private_key.decode_pem (Cstruct.of_string key) with
| Ok `RSA key -> key
| Ok _ -> failwith "unsupported key type, only RSA supported"
| Error `Msg m -> failwith ("error decoding key: " ^ m)
match X509.Private_key.decode_pem (Cstruct.of_string key) with
| Ok `RSA key -> key
| Ok _ -> failwith "unsupported key type, only RSA supported"
| Error `Msg m -> failwith ("error decoding key: " ^ m)
in
Mirage_crypto_pk.Rsa.pub_of_priv key

Expand Down
1 change: 0 additions & 1 deletion client/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
uri
lwt
lwt.unix
sexplib
cstruct
oca_lib
cmdliner
Expand Down
2 changes: 0 additions & 2 deletions opam-health-check.opam
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ depends: [
"fmt" {>= "0.8.7"}
"re" {>= "1.7.2"}
"yaml" {>= "2.0.0"}
"sexplib" {>= "v0.9.0"}
"sexplib0" {>= "v0.9.0"}
"xdg-basedir" {>= "0.0.4"}
"obuilder-spec" {>= "0.5"}
"ocluster-api" {>= "0.1"}
Expand Down
10 changes: 4 additions & 6 deletions server/backend/admin.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,10 @@ let get_user_key workdir user =
let keyfile = get_keyfile workdir user in
let%lwt key = Lwt_io.with_file ~mode:Lwt_io.Input (Fpath.to_string keyfile) (Lwt_io.read ?count:None) in
Lwt.return
(try Mirage_crypto_pk.Rsa.priv_of_sexp (Sexplib.Sexp.of_string key) with
Sexplib0.Sexp_conv.Of_sexp_error _ ->
match X509.Private_key.decode_pem (Cstruct.of_string key) with
| Ok `RSA key -> key
| Ok _ -> failwith "unsupported key type, only RSA supported"
| Error `Msg m -> failwith ("error decoding key: " ^ m))
(match X509.Private_key.decode_pem (Cstruct.of_string key) with
| Ok `RSA key -> key
| Ok _ -> failwith "unsupported key type, only RSA supported"
| Error `Msg m -> failwith ("error decoding key: " ^ m))

let partial_decrypt key msg =
Cstruct.to_string (Mirage_crypto_pk.Rsa.decrypt ~key (Cstruct.of_string msg))
Expand Down
2 changes: 0 additions & 2 deletions server/backend/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
cohttp-lwt-unix
docker_hub
http-lwt-client
sexplib
sexplib0
cstruct
containers
oca_server
Expand Down

0 comments on commit 9bec7f8

Please sign in to comment.