From 4dea7ae5cf551a3c029b6094135097bed578a709 Mon Sep 17 00:00:00 2001 From: David Macek Date: Tue, 11 Mar 2014 10:48:11 +0100 Subject: [PATCH] ENH: Added support for RPC channel encryption in aria2rpc --- doc/xmlrpc/aria2rpc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/xmlrpc/aria2rpc b/doc/xmlrpc/aria2rpc index cc5bd2b6..427c0603 100755 --- a/doc/xmlrpc/aria2rpc +++ b/doc/xmlrpc/aria2rpc @@ -238,6 +238,8 @@ OptionParser.new do |opt| opt.on("--user USERNAME", "XML-RPC username"){|val| options["user"]=val } opt.on("--passwd PASSWORD", "XML-RPC password"){|val| options["passwd"]=val } + opt.on("--secure [BOOL]",["true","false"]){|val| options["secure"]=val||"true" } + opt.on("--check-rpc-cert [BOOL]",["true","false"]){|val| options["check-rpc-cert"]=val||"true" } opt.on("--secret SECRET", "XML-RPC secret authorization token"){|val| options["secret"]=val } @@ -303,19 +305,32 @@ end if not options.has_key?("port") then options["port"]="6800" end +if not options.has_key?("secure") then + options["secure"]="false" +end +if not options.has_key?("check-rpc-cert") then + options["check-rpc-cert"]="true" +end secret = if options.has_key?("secret") then "token:"+options["secret"] else nil end client=XMLRPC::Client.new3({:host => options["server"], :port => options["port"], :path => "/rpc", :user => options["user"], - :password => options["passwd"]}) + :password => options["passwd"], + :use_ssl => options["secure"]}) + +if options["check-rpc-cert"] == "false" then + client.instance_variable_get(:@http).instance_variable_set(:@verify_mode, OpenSSL::SSL::VERIFY_NONE) +end options.delete("server") options.delete("port") options.delete("user") options.delete("passwd") options.delete("secret") +options.delete("secure") +options.delete("check-rpc-cert") def client_call client, secret, method, *params if secret.nil?