diff --git a/src/client/client_config.ml b/src/client/client_config.ml index 5e4ef8504..4c63d4b6f 100644 --- a/src/client/client_config.ml +++ b/src/client/client_config.ml @@ -85,6 +85,10 @@ let incoming_port = in_both_groups @@ new int_cp [ "port" ] ~short_name:"P" 8732 "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 *) 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 else Lwt.return () end >>= fun () -> + begin + match preparse "-tls" argv with + | None -> () + | Some _ -> tls#set true + end ; begin match preparse "-addr" argv with | None -> () diff --git a/src/client/client_node_rpcs.ml b/src/client/client_node_rpcs.ml index ddeeeccab..bc30389e1 100644 --- a/src/client/client_node_rpcs.ml +++ b/src/client/client_node_rpcs.ml @@ -24,10 +24,12 @@ let cpt = ref 0 let make_request cctxt service json = incr cpt ; let cpt = !cpt in - let serv = "http://" ^ Client_config.incoming_addr#get - ^ ":" ^ string_of_int Client_config.incoming_port#get in - let string_uri = String.concat "/" (serv :: service) in - let uri = Uri.of_string string_uri in + let scheme = if Client_config.tls#get then "https" else "http" in + let host = Client_config.incoming_addr#get in + let port = Client_config.incoming_port#get 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 tzero = Unix.gettimeofday () in catch