File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ import (
26
26
)
27
27
28
28
func init () {
29
+ x509 .SetFallbackRoots (newFallbackCertPool ())
30
+ }
31
+
32
+ func newFallbackCertPool () * x509.CertPool {
29
33
p := x509 .NewCertPool ()
30
34
for _ , c := range mustParse (unparsedCertificates ) {
31
35
if len (c .constraints ) == 0 {
@@ -41,7 +45,7 @@ func init() {
41
45
})
42
46
}
43
47
}
44
- x509 . SetFallbackRoots ( p )
48
+ return p
45
49
}
46
50
47
51
type unparsedCertificate struct {
Original file line number Diff line number Diff line change
1
+ package fallback
2
+
3
+ import "testing"
4
+
5
+ // BenchmarkInitTime benchmarks the time it takes to parse all certificates
6
+ // in this bundle, it corresponds to the init time of this package.
7
+ func BenchmarkInitTime (b * testing.B ) {
8
+ for range b .N {
9
+ newFallbackCertPool ()
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments