]> git.ipfire.org Git - thirdparty/squid.git/commit
sslcrtd_program: Use (more) Squid-wide APIs (#1021)
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 26 Apr 2022 15:11:44 +0000 (15:11 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 26 Apr 2022 16:34:50 +0000 (16:34 +0000)
commit0efecd3284dbeb24436e22f8273b698a985bdc38
treea495306c349f2e0bdb92ad33b6378ecb3adaea7d
parentd1b15c26200fc97ca6023a131f91140498f467dc
sslcrtd_program: Use (more) Squid-wide APIs (#1021)

This switch allows us to use Squid-native debugging and error handling
code in ssl/libsslutil.la. Such use is necessary to fix and enhance
certificate handling code currently located in that library. For now, we
only did straightforward adjustments like fixing parseBytesOptionValue()
and Ssl::CrtdMessage::parseRequest() error detection/handling. More
serious changes deserve dedicated PRs.

This change also converts the remaining bare std::runtime_error uses in
runtime Squid code and almost all std::cerr uses in sslcrtd_program:

* std::runtime_error: TextException provides the source code location of
  the thrower and will be enhanced along with Squid improvements.

* std::cerr: debugs() provides much better runtime logging, on many
  levels. The usage() dump still uses std::cerr because debugs()
  decorations are not useful in that special case and because, IMO, that
  case should be using std::cout instead (it is not reporting an error).

Removing STL APIs (that have Squid-native alternatives) from the old
helper code also reduces the temptation to use wrong APIs in new code,
especially when authors are not familiar with Squid conventions/plans.

Also replaced sslcrtd_program's `Here` hack with SourceLocation.

Also report all started helpers (at debug level 2) because a successful
helper start is a significant event worth reporting (when level-2
debugging is enabled) across all helpers.
src/debug/debug.cc
src/security/cert_generators/file/Makefile.am
src/security/cert_generators/file/certificate_db.cc
src/security/cert_generators/file/certificate_db.h
src/security/cert_generators/file/security_file_certgen.cc
src/ssl/crtd_message.cc
src/ssl/crtd_message.h