aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: bda9f48338631f0944108afd35fb04a3c348796a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# silentct

An implementation of a silent Certificate Transparency monitor.

## Status

Drafty prototype, please do not use for anything too serious yet.

## How it works

A monitor downloads all certificates from Certificate Transparency logs.  This
provides a concise view of which certificates have been issued for what domains.

The monitor is configured to pull certificates from trusted systems that
legitimately request certificates.  The legitimately issued certificates are
typically made available on HTTP(S) URLs that are polled periodically.

To convince the monitor that the file of legitimately issued certificates is
authentic, it is integrity protected using a message authentication code.  So,
the monitor and its trusted systems need to be configured with shared secrets.

What makes this setup "silent" is that the monitor can compute the difference
between any downloaded and legitimately issued certificates.  If a certificate
is found that no trusted system made available, only then an alert is emitted.

See the [silentct design](./docs/design.md) for a lengthier introduction.

## Quickstart

### Setup a trusted system

Install the `silentct-mac` tool.

    $ go install rgdd.se/silentct/cmd/silentct-mac@latest

Mark all certificates that have yet to expire as legitimately issued.  The below
specifies one certificate chain, but it is possible to list multiple ones.

    $ silentct-mac -n example.org -s sikritpassword /etc/letsencrypt/live/example.org/fullchain.pem

`-n` sets an arbitrary name of the trusted system.

`-s` sets a secret that will be shared with the monitor.

The output includes the name, a message authentication code, and the list of
certificate chains that was specified.  Record the output as a file the monitor
can pull, e.g., by saving it in a web root or transferring it to one.  Ensure
that this file gets updated each time a new certificate is legitimately issued.
Below is an example that keeps the file up-to-date with `crontab` and `certbot`.

    # crontab -l
    35 3 * * * certbot renew --post-hook "silentct-mac -n example.org -s sikritpassword -o /var/www/example.org/silentct/allowlist /etc/letsencrypt/live/example.org/fullchain.pem"

**Note:** the `--post-hook` option can be specified per site in the
`[renewalparams]` section of `/etc/letsencrypt/renewal/example.org.conf`.

### Setup the monitor

Install the `silentct-mon` tool:

    $ go install rgdd.se/silentct/cmd/silentct-mon@latest

Create a configuration file.

    $ cat config.json
    {
      "monitor": [
        {
          "bootstrap_at": "2024-01-01T00:00:00Z",
          "suffix": "example.org",
          "excludes": [
            "test"
          ]
        }
      ],
      "certificate_requesters": [
        {
          "name": "example.org",
          "secret": "sikritpassword",
          "location": "https://www.example.org/silentct/allowlist",
          "requests": [
            "example.org",
            "www.example.org"
          ]
        }
      ]
    }

`bootstrap_at` is the time the monitor started looking for certificates that
match `suffix`.  The monitor considers a certificate to match iff (i) it expired
after the bootstrap time, and (ii) at least one subject alternative name ends
with the specified suffix without a longer match being available when taking the
optional `excludes` list of subdomains into account.  For example, the above
configuration matches `www.example.org` but not `foo.test.example.org`.

Each entry in the `"certificate-requesters"` list corresponds to a trusted
system and the domains it requests certificates for.  Set `name`, `secret`,
`location` (filename or URL to pull from), and `requests` to match the
configuration of each trusted system.  The monitor will refuse to mark a
certificate as legitimate unless the trusted system that requested it had
permission to do so.  This adds a layer of separation between trusted systems.

### Start the monitor

Start the monitor:

    $ silentct-mon -c config.json -d ~/.local/lib/silentct

Use the `--bootstrap` flag when running the monitor for the first time.

Noteworthy events will be printed on stdout using the NOTICE level.  If you
prefer to get the monitor's output in a file, use the `-o` option.

### Stop the monitor

Stop the monitor gracefully by sending the SIGINT or SIGTERM signals.  Nothing
bad will happen on an ungraceful exit (just redundant work on next startup).

## Contact

  - Room `#certificate-transparency` at OFTC.net
  - Room `#certificate-transparency` at matrix.org