mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
balls
This commit is contained in:
parent
6e6eb688d7
commit
1cffa33264
7 changed files with 74 additions and 75 deletions
33
modules/http_proxy_cert_cache.go
Normal file
33
modules/http_proxy_cert_cache.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
certCache = make(map[string]*tls.Certificate)
|
||||
certLock = &sync.Mutex{}
|
||||
)
|
||||
|
||||
func getCachedCert(domain string, port int) *tls.Certificate {
|
||||
key := fmt.Sprintf("%s:%d", domain, port)
|
||||
|
||||
certLock.Lock()
|
||||
defer certLock.Unlock()
|
||||
|
||||
if cert, found := certCache[key]; found == true {
|
||||
return cert
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setCachedCert(domain string, port int, cert *tls.Certificate) {
|
||||
key := fmt.Sprintf("%s:%d", domain, port)
|
||||
|
||||
certLock.Lock()
|
||||
defer certLock.Unlock()
|
||||
|
||||
certCache[key] = cert
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue