Skip to content

Commit

Permalink
benchmark certificate issuing
Browse files Browse the repository at this point in the history
  • Loading branch information
DarienRaymond committed Nov 21, 2018
1 parent e99dd29 commit d2d0c69
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions transport/internet/tls/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,27 @@ func TestInsecureCertificates(t *testing.T) {
t.Fatal("Unexpected tls cipher suites list: ", tlsConfig.CipherSuites)
}
}

func BenchmarkCertificateIssuing(b *testing.B) {
certificate := ParseCertificate(cert.MustGenerate(nil, cert.Authority(true), cert.KeyUsage(x509.KeyUsageCertSign)))
certificate.Usage = Certificate_AUTHORITY_ISSUE

c := &Config{
Certificate: []*Certificate{
certificate,
},
}

tlsConfig := c.GetTLSConfig()
lenCerts := len(tlsConfig.Certificates)

b.ResetTimer()

for i := 0; i < b.N; i++ {
_, _ = tlsConfig.GetCertificate(&gotls.ClientHelloInfo{
ServerName: "www.v2ray.com",
})
delete(tlsConfig.NameToCertificate, "www.v2ray.com")
tlsConfig.Certificates = tlsConfig.Certificates[:lenCerts]
}
}

0 comments on commit d2d0c69

Please sign in to comment.