Skip to content

Commit

Permalink
add ssl (HTTPS) support
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Depierrepont <[email protected]>
  • Loading branch information
toorop committed May 26, 2014
1 parent 4e78d6e commit 6c5975d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ Mores examples in example.go (in examples folder)

Documentation
-----
Click on the button below to access the full documentation:

[![GoDoc](https://godoc.org/github.com/Toorop/go-bitcoind?status.png)](https://godoc.org/github.com/Toorop/go-bitcoind)



Unit tests
----
[![Build Status](https://travis-ci.org/Toorop/go-bitcoind.svg)](https://travis-ci.org/Toorop/go-bitcoind)
Expand All @@ -80,14 +84,20 @@ To run tests:
Test Suite Passed




Todo
-----
* https
* GetBlockTemplate
* sendrawtransaction
* signrawtransaction
* submitblock

#####Note on SSL support

Note on ssl support : bitcoind library doesn't verify the server's certificate chain. That means that it accepts any certificate presented by the server and any host name in that certificate. In this mode, TLS is susceptible to man-in-the-middle attacks.


Donation
------

Expand Down
10 changes: 8 additions & 2 deletions rpcClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package bitcoind

import (
"bytes"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
//"strings"
"time"
)

Expand Down Expand Up @@ -45,12 +45,18 @@ func newClient(host string, port int, user, passwd string, useSSL bool) (c *rpcC
return
}
var serverAddr string
var httpClient *http.Client
if useSSL {
serverAddr = "https://"
t := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
httpClient = &http.Client{Transport: t}
} else {
serverAddr = "http://"
httpClient = &http.Client{}
}
c = &rpcClient{serverAddr: fmt.Sprintf("%s%s:%d", serverAddr, host, port), user: user, passwd: passwd, httpClient: &http.Client{}}
c = &rpcClient{serverAddr: fmt.Sprintf("%s%s:%d", serverAddr, host, port), user: user, passwd: passwd, httpClient: httpClient}
return
}

Expand Down

0 comments on commit 6c5975d

Please sign in to comment.