Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow using self signed certificates #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ package gorqlite

*/

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

/* *****************************************************************

Expand Down
21 changes: 16 additions & 5 deletions gorqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ package gorqlite
Open, TraceOn(), TraceOff()
*/

import "crypto/rand"
import "fmt"
import "io"
import "io/ioutil"
import "strings"
import (
"crypto/rand"
"crypto/tls"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
)

/* *****************************************************************

Expand Down Expand Up @@ -51,6 +55,8 @@ const (
api_WRITE
)

var InsecureSkipVerify bool

/* *****************************************************************

init()
Expand Down Expand Up @@ -112,6 +118,11 @@ func Open(connURL string) (Connection, error) {
return conn, err
}

if conn.wantsHTTPS {
// allow using self signed certificates
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: InsecureSkipVerify}
}

// call updateClusterInfo() to populate the cluster
// also tests the user's default

Expand Down