Comments (4)
req uses http.Client, you can customize the client, for example:
package main
import (
"crypto/tls"
"crypto/x509"
"github.com/imroc/req"
"io/ioutil"
"log"
"net/http"
)
const (
localCertFile = "/usr/local/internal-ca/ca.crt"
)
func main() {
// Get the SystemCertPool, continue with an empty pool on error
rootCAs, _ := x509.SystemCertPool()
if rootCAs == nil {
rootCAs = x509.NewCertPool()
}
// Read in the cert file
certs, err := ioutil.ReadFile(localCertFile)
if err != nil {
log.Fatalf("Failed to append %q to RootCAs: %v", localCertFile, err)
}
// Append our cert to the system pool
if ok := rootCAs.AppendCertsFromPEM(certs); !ok {
log.Println("No certs appended, using system certs only")
}
// Trust the augmented cert pool in our client
config := &tls.Config{
InsecureSkipVerify: false,
RootCAs: rootCAs,
}
tr := &http.Transport{TLSClientConfig: config}
client := &http.Client{Transport: tr}
req.SetClient(client)
}
from req.
thx && understood, but given kennethreitz/requests can handle certs conveniently, shall we make the analogical APIs available?
from req.
sounds great, I'll consider this
from req.
v2 support this, try and enjoy :)
from req.
Related Issues (20)
- 使用代理时代理服务器需要认证如何使用呢? HOT 2
- 上传与下载过程, 中途怎么取消呢? HOT 1
- 发送大量 HTTP 请求时,如何为每个请求单独指定代理? HOT 2
- Question about the `DisableForceMultipart` HOT 2
- ImpersonateChrome - tls: user canceled HOT 2
- 请问怎么设置请求头变量大写不转换成小写 HOT 2
- 使用h2协议,设置随机TLS指纹的时候出现问题:http2: unexpected ALPN protocol ""; want "h2" HOT 1
- 希望增加允许设置查询参数的排序
- invalid memory address or nil pointer dereference
- connect: cannot assign requested address 如何优化 HOT 2
- How do I set a timeout for a get or post request? For example, if no data is returned within 3 seconds, it is considered a failure HOT 1
- digest认证,获取body为nil,怎么能获取到数据 HOT 8
- Will it support socks5h HOT 1
- Proxy over HTTP3 doesn't work HOT 1
- HTTP3 doesn't work even when forced?
- Add SECURITY.md HOT 2
- Imroc can't read response correctly HOT 5
- 使用ImpersonateChrome方法绕不过cf的5秒盾 HOT 2
- info.FileSize empty in SetUploadCallback() when using SetFileReader() HOT 2
- retry之后的cookies会重复追加 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from req.