You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/index.gmi
+72-14Lines changed: 72 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -38,19 +38,11 @@ Download the source code and run `cargo build --release` inside the source repos
38
38
You can use the install script in the `tools` directory for the remaining steps if there is one for your system. If there is none, please consider contributing one to make it easier for less tech-savvy users!
39
39
***
40
40
41
-
2. Generate a self-signed TLS certificate and private key. For example, if you have OpenSSL 1.1 installed, you can use a command like the following. (Replace the hostname `example.com` with the address of your Gemini server.)
3. Run the server. You can use the following arguments to specify the locations of the content directory, certificate and key files, IP address and port to listen on, host name to expect in request URLs, and default language code(s) to include in the MIME type for for text/gemini files: (Again replace the hostname `example.com` with the address of your Gemini server.)
41
+
2. Run the server. You can use the following arguments to specify the locations of the content directory, IP address and port to listen on, host name to expect in request URLs, and default language code to include in the MIME type for for text/gemini files: (Replace the hostname `example.com` with the address of your Gemini server.)
42
+
If you have not done it yourself, Agate will generate a private key and certificate for you on the first run, using the specified hostname(s). See the section Certificates below for more.
49
43
50
44
```
51
45
agate --content path/to/content/ \
52
-
--key key.rsa \
53
-
--cert cert.pem \
54
46
--addr [::]:1965 \
55
47
--addr 0.0.0.0:1965 \
56
48
--hostname example.com \
@@ -107,7 +99,7 @@ Agate will use this MIME type instead of what it would guess, if the file is fou
107
99
If a line violates the format or looks like case 3, but is incorrect, it might be ignored. You should check your logs. Please know that this configuration file is first read when a file from the respective directory is accessed. So no log messages after startup does not mean the `.meta` file is okay.
108
100
109
101
Such a configuration file might look like this:
110
-
```text
102
+
```
111
103
# This line will be ignored.
112
104
**/*.de.gmi: ;lang=de
113
105
nl/**/*.gmi: ;lang=nl
@@ -135,17 +127,59 @@ any non-hidden file in the `nl` directory ending in `.gmi` (including in non-hid
135
127
136
128
### Logging Verbosity
137
129
138
-
Agate uses the `env_logger` crate and allows you to set the logging verbosity by setting the default `RUST_LOG` environment variable. For more information, please see the documentation of `env_logger`.
130
+
Agate uses the `env_logger` crate and allows you to set the logging verbosity by setting the default `RUST_LOG` environment variable. To turn off all logging use `RUST_LOG=off`. For more information, please see the documentation of `env_logger`.
139
131
=> https://docs.rs/env_logger/0.8 documentation of `env_logger` crate
140
132
141
133
### Virtual Hosts
142
134
143
135
Agate has basic support for virtual hosts. If you specify multiple `--hostname`s, Agate will look in a directory with the respective hostname within the content root directory.
144
136
For example if one of the hostnames is `example.com`, and the content root directory is set to the default `./content`, and `gemini://example.com/file.gmi` is requested, then Agate will look for `./content/example.com/file.gmi`. This behaviour is only enabled if multiple `--hostname`s are specified.
145
-
Agate does not support different certificates for different hostnames, you will have to use a single certificate for all domains (multi domain certificate).
137
+
Agate also supports different certificates for different hostnames, see the section on certificates below.
146
138
147
139
If you want to serve the same content for multiple domains, you can instead disable the hostname check by not specifying `--hostname`. In this case Agate will disregard a request's hostname apart from checking that there is one.
148
140
141
+
### Certificates
142
+
143
+
Agate has support for using multiple certificates with the `--certs` option. Agate will thus always require that a client uses SNI, which should not be a problem since the Gemini specification also requires SNI to be used.
144
+
145
+
Certificates are by default stored in the `.certificates` directory. This is a hidden directory for the purpose that uncautious people may set the content root directory to the currrent director which may also contain the certificates directory. In this case, the certificates and private keys would still be hidden. The certificates are only loaded when Agate is started and are not reloaded while running. The certificates directory may directly contain a key and certificate pair, this is the default pair used if no other matching keys are present. The certificates directory may also contain subdirectories for specific domains, for example a folder for `example.org` and `portal.example.org`. Note that the subfolders for subdomains (like `portal.example.org`) should not be inside other subfolders but directly in the certificates directory. Agate will select the certificate/key pair whose name matches most closely. For example take the following directory structure:
146
+
147
+
```
148
+
.certificates
149
+
|-- cert.pem (1)
150
+
|-- key.rsa (1)
151
+
|-- example.org
152
+
| |-- cert.pem (2)
153
+
| `-- key.rsa (2)
154
+
`-- portal.example.org
155
+
|-- cert.pem (3)
156
+
`-- key.rsa (3)
157
+
```
158
+
159
+
This would be understood like this:
160
+
* The certificate/key pair (1) would be used for the entire domain tree (exceptions below).
161
+
* The certificate/key pair (2) would be used for the entire domain tree of `example.org`, so also including subdomains like `secret.example.org`. It overrides the pair (1) for this subtree (exceptions below).
162
+
* The certificate/key pair (3) would be used for the entire domain tree of `portal.example.org`, so also inclduding subdomains like `test.portal.example.org`. It overrides the pairs (1) and (2) for this subtree.
163
+
164
+
Using a directory named just `.` causes undefined behaviour as this would have the same meaning as the top level certificate/key pair (pair (1) in the example above).
165
+
166
+
The files for a certificate/key pair have to be named `cert.der` and `key.der` respectively. The certificate has to be a X.509 certificate in a DER format file and has to include a subject alt name of the domain name. The private key has to be in DER format and must be either an RSA, ECDSA or Ed25519 key.
167
+
If the `--hostname` argument is used, Agate will generate certificates and Ed25519 certificates for each hostname specified.
168
+
169
+
## Logging
170
+
171
+
All requests will be logged using this format:
172
+
```
173
+
<local ip>:<local port> <remote ip or dash> "<request>" <response status> "<response meta>"[ error:<error>]
174
+
```
175
+
The "error:" part will only be logged if an error occurred. This should only be used for informative purposes as the status code should provide the information that an error occurred. If the error consisted in the connection not being established (e.g. because of TLS errors), the status code `00` will be used.
176
+
177
+
There are some lines apart from these that might occur in logs depending on the selected log level. For example the initial "Listening on..." line or information about listing a particular directory.
178
+
179
+
## Security considerations
180
+
181
+
If you want to run agate on a multi-user system, you should be aware that all certificate and key data is loaded into memory and stored there until the server stops. Since the memory is also not explicitly overwritten or zeroed after use, the sensitive data might stay in memory after the server has terminated.
182
+
149
183
# Changelog
150
184
151
185
All notable changes to this project will be documented in this file.
@@ -154,7 +188,31 @@ The format is based on Keep a Changelog and this project adheres to Semantic Ver
154
188
=> https://keepachangelog.com/en/1.0.0/ Keep a Changelog home page
155
189
=> https://semver.org/spec/v2.0.0.html Semantic versioning standard v2.0.0
156
190
157
-
## [Unreleased]
191
+
## [3.0.0] - 2021-03-27
192
+
Thank you to @ddevault for contributing to this release.
193
+
194
+
### Added
195
+
* Support for ECDSA and Ed25519 keys.
196
+
* Agate now generates certificates and keys for each `--hostname` that is specified but no matching files exist. (#41)
197
+
198
+
### Changed
199
+
* The ability to specify a certificate and key with `--cert` and `--key` respectively has been replaced with the `--certs` option. (#40)
200
+
Certificates are now stored in a special directory. To migrate to this version, the keys should be stored in the `.certificates` directory (or any other directory you specify).
201
+
This enables us to use multiple certificates for multiple domains.
202
+
* The certificate and key file format has been changed from PEM to DER. This simplifies loading certificate and key files without relying on unstable portions of other crates.
203
+
If you want to continue using your existing certificates and keys, please convert them to DER format. You should be able to use these commands if you have openssl installed:
204
+
```
205
+
openssl x509 -in cert.pem -out cert.der -outform DER
206
+
openssl rsa -in key.rsa -out key.der -outform DER
207
+
```
208
+
Since agate will automatically generate certificates from now on, the different format should not be a problem because users are not expected to handle certificates unless experienced enough to be able to handle DER formatting as well.
209
+
210
+
### Fixed
211
+
* Agate now requires the use of SNI by any connecting client.
212
+
* All log lines are in the same format now:
213
+
`<local ip>:<local port> <remote ip or dash> "<request>" <response status> "<response meta>" [error:<error>]`
214
+
If the connection could not be established correctly (e.g. because of TLS errors), the status code `00` is used.
215
+
* Messages from modules other than Agate itself are not logged by default.
158
216
159
217
## [2.5.3] - 2021-02-27
160
218
Thank you to @littleli and @06kellyjac for contributing to this release.
0 commit comments