diff options
| -rw-r--r-- | x509roots/fallback/fallback.go | 6 | ||||
| -rw-r--r-- | x509roots/fallback/fallback_test.go | 11 |
2 files changed, 16 insertions, 1 deletions
diff --git a/x509roots/fallback/fallback.go b/x509roots/fallback/fallback.go index 0f0e3a9..e4b5339 100644 --- a/x509roots/fallback/fallback.go +++ b/x509roots/fallback/fallback.go @@ -26,6 +26,10 @@ import ( ) func init() { + x509.SetFallbackRoots(newFallbackCertPool()) +} + +func newFallbackCertPool() *x509.CertPool { p := x509.NewCertPool() for _, c := range mustParse(unparsedCertificates) { if len(c.constraints) == 0 { @@ -41,7 +45,7 @@ func init() { }) } } - x509.SetFallbackRoots(p) + return p } type unparsedCertificate struct { diff --git a/x509roots/fallback/fallback_test.go b/x509roots/fallback/fallback_test.go new file mode 100644 index 0000000..e380046 --- /dev/null +++ b/x509roots/fallback/fallback_test.go @@ -0,0 +1,11 @@ +package fallback + +import "testing" + +// BenchmarkInitTime benchmarks the time it takes to parse all certificates +// in this bundle, it corresponds to the init time of this package. +func BenchmarkInitTime(b *testing.B) { + for range b.N { + newFallbackCertPool() + } +} |
