Files
demo/examples/other/https/https_proxy.go
2025-03-14 18:50:49 +00:00

28 lines
606 B
Go

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)
}
}