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)
- 使用 https 代理 访问网站报错 HOT 1
- Hijack H1 Connection (e.g. for using as Websocket) HOT 2
- H2 release the stream reservation HOT 3
- http1.1的user-agent问题
- Custom TLS Version, SNI, ALPN, CipherSuite, Support ESNI (ECH) / Supported Proxy Types
- Is it safe to call client.SetLogger(logger) concurrently? HOT 5
- why "trace is not enabled" when RemoteAddr is nil? HOT 2
- 多协程下使用ImpersonateChrome直接报错
- 能否添加extensionECH的支持
- ImpersonateFirefox - connection error: PROTOCOL_ERROR
- ImpersonateFirefox - ECDSA verification failure HOT 2
- 看了文档之后,我知道了如何构建一个正常的请求,但如果我想构建这样的请求,请问应该怎么写才行。 HOT 2
- 向ChatGPT接口发送请求时,无法通过TLS指纹校验 HOT 2
- 关于cookie的疑问 HOT 4
- Does req support passing context from outside? HOT 2
- utls已经更新ECH的支持 ,能否同步更新一下 HOT 1
- Go 1.21 Support HOT 4
- 解gzip之后的render会panic HOT 2
- 我该怎么传递 binary 数据?
- ContentLength优化问题 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.