[gnutls-devel] Speedup idea...

Tim Ruehsen tim.ruehsen at gmx.de
Wed Aug 3 10:19:54 CEST 2016

Hi Nikos,

thanks for your answer.

On Wednesday, August 3, 2016 6:43:39 AM CEST Nikos Mavrogiannopoulos wrote:
> Hi Tim,
>  During handshake you must have a certificate credentials structure set or
> the handshake will fail as you say. It may be empty though,  it doesn't
> need to have ca certificates set. You can load these prior to calling the
> certificate verify peers function.

Fine, thanks gain. It works as you say.

> This violates the rule that the credentials must be read only after being
> set on a session, but on client side they are only used during
> verification. An alternative approach is to verify the peers certificates
> using a trust list.

My goal is to only load that CA cert(s) that really have to be checked 
against. I need to create a hash from the server certs which 'point' to the CA 
cert files on disk, like OpenSSL already does. Well, we talked about that in 
the past and you pointed me to p11kit... but in fact, I so far do not really 
have a 'big picture' - the p11kit docs are mostly technical details, no 
understandable explanation what 's it all about.

> Btw out of curiosity,  have you tested the same operation in fedora which
> uses the p11kit trust module instead of files?

I don't have a fedora VM installed. If you have (and have time), maybe you 
send me the output of 'wget -d https://www.google.com/a.html' - makes only 
sense if wget is linked to GnuTLS, of course.

Regards, Tim

> On 2 August 2016 16:47:54 CEST, Tim Ruehsen <tim.ruehsen at gmx.de> wrote:
> >Hi Nikos, hi list.
> >
> >Right after gnutls_init() the wget/wget2 code loads the certificate
> >list - all
> >available certs. That currently are 172 CA certs on Debian Sid right
> >now.
> >
> >This takes 15-20ms here (i3, 3.1GHz), when the files are already
> >cached.
> >
> >With session resumption (or False Start) and TCP Fast Open I just have
> >1xRTT
> >tradeoff for TLS handshake. With slightly less than 33ms RTT that let's
> >me
> >theoretically fetch a file via HTTPS in ~66ms. But I have this damn
> >load-them-
> >all-CA (gnutls_certificate_set_x509_system_trust()) taking another
> >15ms, so I
> >am at ~81ms for fetching a file. This is quite a big portion of the
> >overall
> >download time - having lower RTT makes this relation even worse.
> >
> >My quick solution was (I thought it could work), why not load the certs
> >during
> >the handshake. Right after the first write(), when the handshake waits
> >for the
> >server answer, I have 33ms of time that I can use for loading.
> >
> >But then... in ciphersuites.c/_gnutls_remove_unwanted_ciphersuites(),
> >you
> >"unload" all ciphersuites not needed by the certs, resulting in an
> >error if no
> >certs are loaded (because having 0 ciphersuites for client hello).
> >
> >But everything works like a charm (I really have just 66ms total time)
> >when I
> >remove these lines from
> >
> >ciphersuites.c/_gnutls_remove_unwanted_ciphersuites():
> >		if (!session->internals.premaster_set &&
> >		
> >		    _gnutls_get_kx_cred(session, kx) == NULL) {
> >			
> >			continue;
> >		
> >		}
> >
> >I guess, all cipher suites known by GnuTLS (or set via priorities) are
> >offered
> >by the client hello !?
> >
> >What can we/I do to make the above scenario 'officially' work ?
> >Wouldn't it be good to offer all cipher suites set by
> >gnutls_priority_set() ?
> >AFAIR, OpenSSL do not need certs to be loaded before client hello...
> >but I
> >might be wrong.
> >
> >Regards, Tim
> >
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >Gnutls-devel mailing list
> >Gnutls-devel at lists.gnutls.org
> >http://lists.gnupg.org/mailman/listinfo/gnutls-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: </pipermail/attachments/20160803/80f38d61/attachment.sig>

More information about the Gnutls-devel mailing list