add --notls option to disable connecting with TLS

ok oga@
This commit is contained in:
David Hill 2013-11-26 20:13:31 -05:00
parent 295cc873f4
commit 9e57a6c5be
2 changed files with 5 additions and 4 deletions

View file

@ -274,7 +274,10 @@ func makeVerifyChain(args []interface{}) (btcjson.Cmd, error) {
func send(cfg *config, msg []byte) (interface{}, error) {
var reply btcjson.Reply
var err error
if cfg.RPCCert != "" || cfg.TlsSkipVerify {
if cfg.NoTls || (cfg.RPCCert == "" && !cfg.TlsSkipVerify) {
reply, err = btcjson.RpcCommand(cfg.RPCUser, cfg.RPCPassword,
cfg.RPCServer, msg)
} else {
var pem []byte
if cfg.RPCCert != "" {
pem, err = ioutil.ReadFile(cfg.RPCCert)
@ -285,9 +288,6 @@ func send(cfg *config, msg []byte) (interface{}, error) {
reply, err = btcjson.TlsRpcCommand(cfg.RPCUser,
cfg.RPCPassword, cfg.RPCServer, msg, pem,
cfg.TlsSkipVerify)
} else {
reply, err = btcjson.RpcCommand(cfg.RPCUser, cfg.RPCPassword,
cfg.RPCServer, msg)
}
if err != nil {
return nil, err

View file

@ -26,6 +26,7 @@ type config struct {
RPCPassword string `short:"P" long:"rpcpass" default-mask:"-" description:"RPC password"`
RPCServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"`
RPCCert string `short:"c" long:"rpccert" description:"RPC server certificate chain for validation"`
NoTls bool `long:"notls" description:"Disable TLS"`
TlsSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"`
}