I'll try to transcribe details later (probably want a public doc and Intent to Implement mail so folks know about the temporary preprocessor #ifdef when we get there). Filing this so we can cite it in bugs:
Certificates are currently represented in-memory as some combination of:
- X509* if owned by BoringSSL (SSL and SSL_SESSION).
- OSCertHandle elsewhere. This, on Android, is an X509* and an OS handle elsewhere.
The OS handles are decent memory-wise, but they don't get deduplicated with the session cache and can't be used in the sandbox.
OpenSSL's legacy X509* object is horrid. Instrumenting allocations from a few sample certificates suggest a freshly-parsed[*] X509* retains about 100 malloc'd objects totaling 4-5x the size of the original byte string. This is nuts. Parsing is also expensive, which has showed up on loading resources from cache.
Replace everything with BoringSSL's new CRYPTO_BUFFER type which should fix all of this.
[*] An X509* additionally has some lazily-computed cached objects hanging off of it. If we hit codepaths that instantiates those, it will be even worse.
Comment 1 by xunji...@chromium.org
, Dec 6 2016