]> git.ipfire.org Git - thirdparty/squid.git/commit - src/security/cert_generators/file/certificate_db.h
Avoid SSL certificate db corruption with empty index.txt as a symptom.
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Thu, 9 Jul 2015 14:02:07 +0000 (17:02 +0300)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Thu, 9 Jul 2015 14:02:07 +0000 (17:02 +0300)
commit541e6ab52ab4dd7e4c8cb2cbe5f173e6de6b8d6d
tree553dbaf95de22747ab20527f261b55a29f5445a3
parentce74a2ebb78c728378d8b9520f0c8489d9415aaa
Avoid SSL certificate db corruption with empty index.txt as a symptom.

* Detect cases where the size file is corrupted or has a clearly wrong
  value. Automatically rebuild the database in such cases.

* Teach ssl_crtd to keep running if it is unable to store the generated
  certificate in the database. Return the generated certificate to Squid
  and log an error message in such cases.

Background:

There are cases where ssl_crtd may corrupt its certificate database.
The known cases manifest themselves with an empty db index file.  When
that happens, ssl_crtd helpers quit, SSL bumping does not work any more,
and the certificate DB has to be deleted and re-initialized.

We do not know exactly what causes corruption in deployments, but one
known trigger that is easy to reproduce in a lab is the block size
change in the ssl_crtd configuration. That change has the following
side-effects:

1. When ssl_crtd removes certificates, it computes their size using a
   different block size than the one used to store the certificates.
   This is may result in negative database sizes.

2. Signed/unsigned conversion results in a huge number near LONG_MAX,
   which is then written to the "size" file.

3. The ssl_crtd helper remoces all certificates from database trying to make
   space for new certificates.

4. The ssl_crtd helper refuses to store new certificates because the
   database size (as described by the "size" file) still exceeds the
   configured limit.

5. The ssl_crtd helper exits because it cannot store a new certificates
   to the database. No helper response is sent to Squid in this case.

Most likely, there are other corruption triggers -- the database
management code is of an overall poor quality. This change resolves some
of the underlying problems in hope to address at least some of the
unknown triggers as well as the known one.

This is a Measurement Factory project.
src/ssl/certificate_db.cc
src/ssl/certificate_db.h
src/ssl/ssl_crtd.cc