-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreateDialer.go
45 lines (33 loc) · 933 Bytes
/
createDialer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package SecureClient
/*
Create SSL Pinned TLS dialer
- This is an INIT function, should only be called once per run max
- New clients use the DialTLS created by the *hpkp.DialerConfig
*/
import (
"errors"
"github.com/tam7t/hpkp"
)
func (p *SSLPinner) CreateDialer() error {
pinChannel := make(chan PinnedSite, 1000)
//fmt.Println("Generating pins!")
go p.GeneratePins(pinChannel)
s := hpkp.NewMemStorage()
for pinned := range pinChannel {
if pinned.Failed && p.RequireAll { return errors.New("Error creating secure client!") }
//fmt.Println(pinned.Host, "Secured -", len(pinned.Pins), "generated")
s.Add(pinned.Host, &hpkp.Header{
Permanent: true,
Sha256Pins: pinned.Pins,
})
}
p.DialerConfig = &hpkp.DialerConfig{
Storage: s,
PinOnly: true,
TLSConfig: nil,
Reporter: func(p *hpkp.PinFailure, reportUri string) {
//fmt.Println("Pin failure: ", p)
},
}
return nil
}