Skip to main content
CLI man page: safesquid-sslcert(5)
CONNECT policy flow

CONNECT policy flow

Overview

HTTPS Inspection controls CONNECT handling and optional TLS man-in-the-middle (Deep Scan) for HTTP inside HTTPS. Requires a valid RCSC (root CA) loaded from activation; the policy engine returns no policy when the section is off or misconfigured. Enabled Master switch ( ssl_policy ). Off: no inspection policy applies. Inspection Policies Profile rows; first match wins. Sets Deep Scan, no-certificate, domain-mismatch, and max SSL error level for that CONNECT. Setup Stored server/ passphrase rows (see field help — not read by current runtime setup code). SSL Certs/Cache Download, upload, or refresh RCSC files and view SSL session/context cache. On CONNECT, deep_scan_check() loads the first matching Inspection

Core Mechanics (C++ Source Validation)

  • Deep Scan (MITM): The connection evaluator determines if deepscan is enabled for the connection. If true, SafeSquid performs full Man-in-the-Middle interception by generating a forged, trusted certificate for the client using the defined Root CA, enabling inspection of the encrypted payload.
  • Upstream Validation: SafeSquid builds an OpenSSL certificate store and verification parameters to validate the upstream origin server’s certificate against known CA authorities.
  • Strict Error Handling: Handlers validate domain mismatches (block_domain_mismatch), missing certificates (block_no_cert), and maximum allowable OpenSSL error levels (max_error_level). Failures drop the connection to prevent MITM attacks from malicious servers.

Schema Fields

Global Fields

  • Enabled (enabled): Master switch for HTTPS Inspection. Off: The policy engine returns NULL and the inspection engine never enables Deep Scan. On: policies apply only when RCSC setup succeeds.

Rule-Based Fields (Per Connection Tuning)

  • Enabled (enabled): When disabled, this row is skipped. First matching enabled row wins for each CONNECT.
  • Comment (comment): Operator note only; not used in SSL verification logs.
  • Profiles (profiles): Connection must match at least one listed profile (Access Profiles engine). Leave blank for all connections. Negated tags ( !profile ) skip the row when that profile is present. The engine stops at the first matching row from the top.
  • DeepScan (deepscan): When TRUE, the inspection engine returns TRUE and SafeSquid performs a client TLS handshake on CONNECT, decrypting HTTP for inspection. When FALSE, CONNECT is tunneled without decrypting; upstream SSL checks in this row are not applied to tunneled traffic. Use FALSE for non-HTTP TLS (Drive, Subversion, WinSCP, etc.).
  • Block Access to Sites that do not have an SSL Certificate (block_no_cert): When TRUE (default), upstream validation blocks if the upstream presents no certificate. When FALSE, connections without a server certificate are allowed to continue (logged at DEBUG).
  • Acceptable Errors in SSL Verification (block_err_level): Maximum OpenSSL verification error SafeSquid tolerates on the upstream certificate. Upstream validation blocks when error limits are exceeded. Level 0 is strictest — only a fully valid chain passes. Hostname and IP mismatch are also gated by Block domain mismatch separately.
  • Block domain mismatch in the web-site SSL certificate (block_domain_mismatch): When TRUE (default), hostname or IP mismatch errors from OpenSSL block the connection. When FALSE, X509_V_ERR_HOSTNAME_MISMATCH and X509_V_ERR_IP_ADDRESS_MISMATCH are explicitly allowed even if they exceed the acceptable error level.
  • Enabled (enabled): When disabled, this Setup row is skipped when the list is rebuilt on config reload. Note: rows are loaded into server_config_list but no runtime code in this tree reads that list (see ambiguities).
  • Comment (comment): Operator note only; not referenced by SSL setup code.
  • Proxy Host (proxy_server): Intended to match this SafeSquid instance (hostname from startup parameters) so the row applies on the correct node.
  • Encrypted Password (enc_pwd): Encrypted passphrase for the RCSC private key, stored per Setup row. Runtime RCSC load uses the global activation password, not this field, in the current build.
  • SSL Cache Store Size (ssl_cache_store_size): Intended cap for outbound SSL context/session cache entries ( CTXcacheOUT ). Stored on each server_config row but not applied by current cache code (cache sizing is internal to CTXcacheOUT ). Changing cache behaviour requires a restart when supported.
  • appcontent (appcontent): No description provided.

How CONNECT is handled

  1. On CONNECT, the inspection engine loads the first matching Inspection Policy row.
  2. When Deep Scan is FALSE, CONNECT is forwarded as a tunnel without decrypting application data.
  3. When Deep Scan is TRUE and RCSC is valid, SafeSquid completes a client-side TLS handshake and decrypts HTTP for filtering.
  4. Before decrypting, the validation engine checks the upstream certificate (no cert, error level, domain mismatch rules).
  5. Deep Scan only works when the tunneled protocol is HTTP; many non-HTTP TLS clients break when forced through inspection.

Inspection Policy fields

  • DeepScan — TRUE enables client TLS handshake and HTTP inspection. FALSE tunnels HTTPS without decrypting.
  • Block Access to Sites that do not have an SSL Certificate — When TRUE (default), block if upstream presents no certificate.
  • Acceptable Errors in SSL Verification — Maximum OpenSSL verification error tolerated on the upstream chain. Level 0 is strictest. Hostname/IP mismatch is gated separately by Block domain mismatch.
  • Block domain mismatch in the web-site SSL certificate — When TRUE (default), hostname or IP mismatch errors block. When FALSE, mismatch errors are allowed even if they exceed the acceptable error level.
  • Profiles — First matching enabled row from the top applies. Blank matches all connections.

Code quirks — Setup subsection unused at runtime

Setup rows are not used by current SSL setup code. Fields Proxy Host, Encrypted Password, and SSL Cache Store Size are loaded into the internal configuration loader decrypts and loads the root CA using the global activation password only — not Setup row passphrases. Cache sizing is internal to CTXcacheOUT; Setup SSL Cache Store Size is not applied. Treat Setup as operator reference until wired in code; use activation for the RCSC passphrase and SSL Certs/Cache for certificate files.

Examples

1 — Inspect general web browsing

  • Enabled: on, valid RCSC from activation
  • Inspection row: Profiles blank, DeepScan TRUE, strict certificate checks
  • Clients trust RCSC public cert
Result: HTTP inside HTTPS is decrypted and passed through the normal filter pipeline.

2 — Tunnel non-HTTP TLS (Drive, Git, RDP-over-TLS)

  • Row A (top): Profiles for known non-HTTP apps, DeepScan FALSE
  • Row B: Profiles blank, DeepScan TRUE
Result: matching non-HTTP CONNECT tunnels without decryption; general HTTPS still inspected via row B.

3 — Allow self-signed upstream with strict client trust

  • Acceptable Errors: relaxed level for internal sites
  • Block domain mismatch: TRUE for public sites, FALSE on a row matching internal host profiles
Result: internal servers with name mismatch may pass upstream validation while public sites remain strict.
  • Deploy RCSC to all managed clients before enabling Deep Scan broadly.
  • Use DeepScan FALSE rows for protocols that are not HTTP-over-TLS.
  • Use SSL Certs/Cache to upload corporate roots and refresh caches after certificate changes.
  • Do not rely on Setup Encrypted Password for RCSC unlock — use activation passphrase.

How to verify

  1. CONNECT to an HTTPS site; confirm filters (for example ClamAV) see decrypted content when DeepScan is TRUE.
  2. Enable SSL log level for SSLcertSection:: and certificate validation lines.
  3. Check Detailed logs for CONNECT handling and upstream certificate errors.
  4. SSL Certs/Cache → Cache Refresh after RCSC or trusted-CA changes.