Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/tls: cache TLS (client) cert validation? #8580

gopherbot opened this issue Aug 24, 2014 · 4 comments

crypto/tls: cache TLS (client) cert validation? #8580

gopherbot opened this issue Aug 24, 2014 · 4 comments


Copy link

@gopherbot gopherbot commented Aug 24, 2014


I'm seeing not-great TLS performance; enabling the ClientSessionCache seems to help. 
But it looks like even when resuming a session, we still call processCertsFromClient,
and do an (expensive) validation of the client cert chain.

Two ideas/questions:

1) Do we really need to re-validate the client cert on resume (haven't we already
validated it on first-connect)?  Can the client switch certs on us?

2) Is it possible to avoid any of this work using a cache?  processCertsFromClient looks
very cacheable to my untrained eye.  I'm thinking something similar to
ClientSessionCache in tls.Config.

I guess I could turn off client-cert validation by the tls package, and implement my own
cache.  It would sure be nice if this was out-of-the-box though!

Session resumption makes this less important, but I don't see why we wouldn't also cache
validation of server certs.

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 25, 2014

Comment 1 by

An update/clarification:
The expensive bit of the cert-chain validation seems to be the EC computations (my code
spends 50% of CPU time in crypto/elliptic.p256ReduceDegree).
I suggest a good approach might be to memoize the crypto computations (which never
change).  So we wouldn't worry about caching usage verifications or expiration times,
and would rely on the standard caching of e.g. CRLs.  I believe those checks are
comparatively cheap, and much harder to cache correctly.

This comment has been minimized.

Copy link

@bradfitz bradfitz commented Aug 25, 2014

Comment 2:

Copying Adam, who owns TLS.
Naively, without knowing the code, it seems like caching EC computations seems sane if
the hit rate is high and the cache is bounded.

Labels changed: added release-go1.4, repo-main.

Status changed to Accepted.


This comment has been minimized.

Copy link

@rsc rsc commented Sep 15, 2014

Comment 3:

Labels changed: added release-none, removed release-go1.4.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc removed release-none labels Apr 10, 2015

This comment has been minimized.

Copy link

@odeke-em odeke-em commented Feb 18, 2017

/cc @agl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.