Last active
October 31, 2019 20:55
-
-
Save jakobii/e5806e40fb32694e242c2a558abcfbf2 to your computer and use it in GitHub Desktop.
Revisions
-
jakobii revised this gist
Oct 31, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func Example() { Username: "admin", TLSConfig: &tls.Config{ RootCAs: roots, InsecureSkipVerify: true, // if its a self signed cert }, }) if err != nil { -
jakobii renamed this gist
Oct 31, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jakobii created this gist
Oct 31, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ package main import ( "crypto/tls" "crypto/x509" "fmt" "io/ioutil" "log" "os" r "gopkg.in/rethinkdb/rethinkdb-go.v5" ) func Example() { roots := x509.NewCertPool() cert, err := ioutil.ReadFile(os.Getenv(`PATH_TO_YOUR_CERT`)) // same cert passed to --driver-tls-cert roots.AppendCertsFromPEM(cert) session, err := r.Connect(r.ConnectOpts{ Address: "YOUR_SERVERS_IP_ADDRESS:28015", Username: "admin", TLSConfig: &tls.Config{ RootCAs: roots, InsecureSkipVerify: true, // if its a self signed cert, skip ndns name check. }, }) if err != nil { log.Fatalln(err) } res, err := r.Expr("Hello World").Run(session) if err != nil { log.Fatalln(err) } var response string err = res.One(&response) if err != nil { log.Fatalln(err) } fmt.Println(response) // Output: // Hello World } func main() { Example() }