init
This commit is contained in:
27
examples/other/https/https_proxy.go
Normal file
27
examples/other/https/https_proxy.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/darkit/goproxy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建证书缓存
|
||||
certCache := &goproxy.MemCertCache{}
|
||||
|
||||
// 创建代理实例,启用 HTTPS 解密
|
||||
proxy := goproxy.NewProxy(
|
||||
goproxy.WithDecryptHTTPS(certCache),
|
||||
goproxy.WithCACertAndKey("ca.crt", "ca.key"),
|
||||
goproxy.WithEnableECDSA(true),
|
||||
)
|
||||
|
||||
// 启动代理服务器
|
||||
log.Println("HTTPS 解密代理服务器启动在 :8080")
|
||||
log.Println("请确保已安装 CA 证书 (ca.crt)")
|
||||
if err := http.ListenAndServe(":8080", proxy); err != nil {
|
||||
log.Fatalf("代理服务器启动失败: %v", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user