mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
fix: fixed a bug in the https.proxy certificates cache due to a race condition which caused the same certificate to be generated more than once
This commit is contained in:
parent
e19595395f
commit
e3573b81e4
2 changed files with 9 additions and 9 deletions
|
@ -11,23 +11,21 @@ var (
|
|||
certLock = &sync.Mutex{}
|
||||
)
|
||||
|
||||
func getCachedCert(domain string, port int) *tls.Certificate {
|
||||
key := fmt.Sprintf("%s:%d", domain, port)
|
||||
func keyFor(domain string, port int) string {
|
||||
return fmt.Sprintf("%s:%d", domain, port)
|
||||
}
|
||||
|
||||
func getCachedCert(domain string, port int) *tls.Certificate {
|
||||
certLock.Lock()
|
||||
defer certLock.Unlock()
|
||||
|
||||
if cert, found := certCache[key]; found {
|
||||
if cert, found := certCache[keyFor(domain, port)]; found {
|
||||
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
|
||||
certCache[keyFor(domain, port)] = cert
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue