MCPcopy
hub / github.com/bettercap/bettercap / ConfigureTLS

Method ConfigureTLS

modules/http_proxy/http_proxy_base.go:300–330  ·  view source on GitHub ↗
(address string, proxyPort int, httpPort int, doRedirect bool, scriptPath string,
	certFile string,
	keyFile string, jsToInject string, stripSSL bool)

Source from the content-addressed store, hash-verified

298}
299
300func (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
332func (p *HTTPProxy) httpWorker() error {
333 p.isRunning = true

Callers 1

ConfigureMethod · 0.80

Calls 2

ConfigureMethod · 0.95
TLSConfigFromCAMethod · 0.95

Tested by

no test coverage detected