(address string, proxyPort int, httpPort int, doRedirect bool, scriptPath string, certFile string, keyFile string, jsToInject string, stripSSL bool)
| 298 | } |
| 299 | |
| 300 | func (p *HTTPProxy) ConfigureTLS(address string, proxyPort int, httpPort int, doRedirect bool, scriptPath string, |
| 301 | certFile string, |
| 302 | keyFile string, jsToInject string, stripSSL bool) (err error) { |
| 303 | if err = p.Configure(address, proxyPort, httpPort, doRedirect, scriptPath, jsToInject, stripSSL); err != nil { |
| 304 | return err |
| 305 | } |
| 306 | |
| 307 | p.isTLS = true |
| 308 | p.Name = "https.proxy" |
| 309 | p.CertFile = certFile |
| 310 | p.KeyFile = keyFile |
| 311 | |
| 312 | rawCert, _ := ioutil.ReadFile(p.CertFile) |
| 313 | rawKey, _ := ioutil.ReadFile(p.KeyFile) |
| 314 | ourCa, err := tls.X509KeyPair(rawCert, rawKey) |
| 315 | if err != nil { |
| 316 | return err |
| 317 | } |
| 318 | |
| 319 | if ourCa.Leaf, err = x509.ParseCertificate(ourCa.Certificate[0]); err != nil { |
| 320 | return err |
| 321 | } |
| 322 | |
| 323 | goproxy.GoproxyCa = ourCa |
| 324 | goproxy.OkConnect = &goproxy.ConnectAction{Action: goproxy.ConnectAccept, TLSConfig: p.TLSConfigFromCA(&ourCa)} |
| 325 | goproxy.MitmConnect = &goproxy.ConnectAction{Action: goproxy.ConnectMitm, TLSConfig: p.TLSConfigFromCA(&ourCa)} |
| 326 | goproxy.HTTPMitmConnect = &goproxy.ConnectAction{Action: goproxy.ConnectHTTPMitm, TLSConfig: p.TLSConfigFromCA(&ourCa)} |
| 327 | goproxy.RejectConnect = &goproxy.ConnectAction{Action: goproxy.ConnectReject, TLSConfig: p.TLSConfigFromCA(&ourCa)} |
| 328 | |
| 329 | return nil |
| 330 | } |
| 331 | |
| 332 | func (p *HTTPProxy) httpWorker() error { |
| 333 | p.isRunning = true |
no test coverage detected