... and more ...

This commit is contained in:
evilsocket 2018-04-26 12:29:59 +02:00
parent 60e8f83b2b
commit e383e4d9b1
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -3,36 +3,17 @@ package tls
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"fmt"
"math/big"
"net"
"sort"
"time"
"github.com/bettercap/bettercap/log"
)
func hashSorted(lst []string) []byte {
c := make([]string, len(lst))
copy(c, lst)
sort.Strings(c)
h := sha1.New()
for _, s := range c {
h.Write([]byte(s + ","))
}
return h.Sum(nil)
}
func hashSortedBigInt(lst []string) *big.Int {
rv := new(big.Int)
rv.SetBytes(hashSorted(lst))
return rv
}
func getServerCertificate(host string, port int) *x509.Certificate {
log.Debug("Fetching TLS certificate from %s:%d ...", host, port)