RPC: Add TLS on the client
This commit is contained in:
parent
77506ac4b5
commit
59881cde32
@ -85,6 +85,10 @@ let incoming_port = in_both_groups @@
|
|||||||
new int_cp [ "port" ] ~short_name:"P" 8732
|
new int_cp [ "port" ] ~short_name:"P" 8732
|
||||||
"The TCP port at which the node's RPC server can be reached."
|
"The TCP port at which the node's RPC server can be reached."
|
||||||
|
|
||||||
|
let tls = in_both_groups @@
|
||||||
|
new bool_cp [ "tls" ] false
|
||||||
|
"Use TLS to connect to node."
|
||||||
|
|
||||||
(* Version specific options *)
|
(* Version specific options *)
|
||||||
|
|
||||||
let contextual_options : (unit -> unit) ref Protocol_hash_table.t =
|
let contextual_options : (unit -> unit) ref Protocol_hash_table.t =
|
||||||
@ -191,6 +195,11 @@ let preparse_args argv cctxt : Node_rpc_services.Blocks.block Lwt.t =
|
|||||||
"Error: can't read the configuration file: %s\n%!" msg
|
"Error: can't read the configuration file: %s\n%!" msg
|
||||||
else Lwt.return ()
|
else Lwt.return ()
|
||||||
end >>= fun () ->
|
end >>= fun () ->
|
||||||
|
begin
|
||||||
|
match preparse "-tls" argv with
|
||||||
|
| None -> ()
|
||||||
|
| Some _ -> tls#set true
|
||||||
|
end ;
|
||||||
begin
|
begin
|
||||||
match preparse "-addr" argv with
|
match preparse "-addr" argv with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
|
@ -24,10 +24,12 @@ let cpt = ref 0
|
|||||||
let make_request cctxt service json =
|
let make_request cctxt service json =
|
||||||
incr cpt ;
|
incr cpt ;
|
||||||
let cpt = !cpt in
|
let cpt = !cpt in
|
||||||
let serv = "http://" ^ Client_config.incoming_addr#get
|
let scheme = if Client_config.tls#get then "https" else "http" in
|
||||||
^ ":" ^ string_of_int Client_config.incoming_port#get in
|
let host = Client_config.incoming_addr#get in
|
||||||
let string_uri = String.concat "/" (serv :: service) in
|
let port = Client_config.incoming_port#get in
|
||||||
let uri = Uri.of_string string_uri in
|
let path = String.concat "/" service in
|
||||||
|
let uri = Uri.make ~scheme ~host ~port ~path () in
|
||||||
|
let string_uri = Uri.to_string uri in
|
||||||
let reqbody = Data_encoding_ezjsonm.to_string json in
|
let reqbody = Data_encoding_ezjsonm.to_string json in
|
||||||
let tzero = Unix.gettimeofday () in
|
let tzero = Unix.gettimeofday () in
|
||||||
catch
|
catch
|
||||||
|
Loading…
Reference in New Issue
Block a user