Skip to content

Instantly share code, notes, and snippets.

@glasser
Created July 21, 2016 23:47
Show Gist options
  • Save glasser/d3af436a877f939f243b351fa1852539 to your computer and use it in GitHub Desktop.
Save glasser/d3af436a877f939f243b351fa1852539 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"log"
"net/http"
cleanhttp "github.com/hashicorp/go-cleanhttp"
)
func main() {
t := cleanhttp.DefaultTransport()
certs, err := ioutil.ReadFile("acme-staging.pem")
if err != nil {
log.Fatal(err)
}
t.TLSClientConfig = &tls.Config{RootCAs: x509.NewCertPool()}
t.TLSClientConfig.RootCAs.AppendCertsFromPEM(certs)
c := &http.Client{Transport: t}
resp, err := c.Get("https://galaxy.test-20160721224638.meet-eeyore.com/")
log.Print(err)
log.Print(resp)
}
var https = require('https');
var fs = require('fs');
https.get({
hostname: 'galaxy.test-20160721224638.meet-eeyore.com',
path: '/',
ca: fs.readFileSync('acme-staging.pem')
}, function (res) {
console.log("got response", res.statusCode);
}).on('error', function (e) {
console.log("got error", e.message);
});
@deltab
Copy link

deltab commented Jul 22, 2016

Hi. Did you notice this in the documentation?

The following options from tls.connect() can also be specified. However, a globalAgent silently ignores these.
[...]
In order to specify these options, use a custom Agent.
[example code]
Alternatively, opt out of connection pooling by not using an Agent.
[example code]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment