Skip to content

Commit 932396a

Browse files
committed
Update README
1 parent 2f956c8 commit 932396a

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

README.md

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,47 @@ A nimble **http** and **echo** server to test arbitrary http requests and REST A
55
`erised [options]`
66
```text
77
Parameters:
8+
-cert string
9+
path to a valid X.509 certificate file
10+
-https
11+
use HTTPS instead of HTTP. A valid X.509 certificate and private key are required
812
-idle int
913
maximum time in seconds to wait for the next request when keep-alive is enabled (default 120)
1014
-json
1115
use JSON log format
16+
-key string
17+
path to a valid private key file
1218
-level string
1319
one of debug/info/warn/error/off (default "info")
1420
-path string
15-
path to search recursively for X-Erised-Response-File (path is restricted to the directory or subdirectories where the program is invoked)
21+
path to search recursively for X-Erised-Response-File
1622
-port int
17-
port to listen (default 8080)
23+
port to listen. Default is 8080 for HTTP and 8443 for HTTPS
24+
-profile string
25+
profile this session. A valid file name is required
1826
-read int
1927
maximum duration in seconds for reading the entire request (default 5)
2028
-write int
2129
maximum duration in seconds before timing out response writes (default 10)
2230
```
2331

24-
For help type **erised -h**
32+
For help type `erised -h`
2533

26-
When executing **erised** with no parameters, the server will listen on port **8080** for incoming http requests.
34+
When executing _erised_ with no parameters, the server will listen on port _8080_ for incoming http requests.
2735

28-
If you're using the _-path_ option, please **EXERCISE GREAT CAUTION** when setting the path to search. See **Known Issues** for more information. For security reasons, path is restricted to the directory or subdirectories where the program was invoked.
36+
If you're using the _-path_ option, please **EXERCISE GREAT CAUTION** when setting the path to search. See **Known Issues** for more information. For security reasons, _path_ is restricted to the directory or subdirectories where the program was invoked.
2937

3038
The latest version is also available as a Docker image at [edaddario/erised](https://hub.docker.com/r/edaddario/erised).
3139

3240
To start the server in a docker container, with defaults values, execute the following command:
3341

3442
```sh
35-
docker run --rm -p 8080:8080 --name erised edaddario/erised [options]
43+
docker run --rm -p 8080:8080 --name erised edaddario/erised
3644
```
3745

3846
If you would like to return file based responses (_X-Erised-Response-File_ set) when using the docker image, you'll need to map the directory containing your local files and set the _-path_ option accordingly.
3947

40-
The following example maps the **/local_directory/response_files** directory in your local machine to **/files** in the docker image, and then sets the **-path** option:
48+
The following example maps the _/local_directory/response_files_ directory in your local machine to _/files_ in the docker image, and then sets the _-path_ option:
4149

4250
```sh
4351
docker run --rm -p 8080:8080 --name erised -v /local_directory/response_files:/files edaddario/erised -path ./files
@@ -52,7 +60,7 @@ URL routes, HTTP methods (e.g. GET, POST, PATCH, etc.), query strings and body a
5260
| erised/ip | GET | Returns the client IP |
5361
| erised/shutdown | POST | Shutdowns the server |
5462

55-
The `erised/echoserver` path will ignore any additional segments after `/echoserver`, including HTTP methods, query strings and body, and it will return a webpage displaying server information and the request's parameters.
63+
The _erised/echoserver_ path will ignore any additional segments after _/echoserver_, including HTTP methods, query strings and body, and it will return a webpage displaying server information and the request's parameters.
5664

5765
| Name | Method | Purpose |
5866
|---------------------|--------|------------------------------------------------------------------------------|
@@ -110,6 +118,7 @@ NetworkAuthenticationRequired or 511
110118
Any other value will resolve to 200 (OK)
111119

112120
# Release History
121+
* v0.11.2 - Add HTTPS capability, add test certificates, add program execution timing, add profiling option, refactor variable names for readability, and replace panics with more user-friendly fatal logs
113122
* v0.9.7 - Refactor error handling
114123
* v0.9.6 - Rename _erised/webpage_ to _erised/echoserver_ and add headers and server environment information
115124
* v0.8.3 - Add _erised/webpage_ path, add multi-architecture docker images, minor refactoring, and minor cosmetic changes
@@ -128,23 +137,47 @@ Any other value will resolve to 200 (OK)
128137
* v0.0.2 - Add HTTP redirection status codes (300's), startup configuration parameters and request's logging
129138
* v0.0.1 - Initial release
130139

140+
# Enabling HTTPS
141+
In order to enable HTTPS support, _erised_ requires a valid X.509 certificate signed by a trusted [Certification Authority](https://en.wikipedia.org/wiki/Certificate_authority) (CA) like [IdenTrust](https://www.identrust.com/), [DigiCert](https://www.digicert.com/) or [Let's Encrypt](https://letsencrypt.org/).
142+
143+
If you don't have one, or would prefer to use a local version, you'll find the necessary certificate ([localCA.pem](./cmd/erised/certs/localCA.pem)) to setup a Root CA in the [/certs](./cmd/erised/certs) folder, which will allow your computer to verify the included test certificate and key. The process to install the CA certificate is beyond the objective of this README, but [Google](https://www.google.com/search?q=how+to+install+trusted+root+certificate) or your favourite AI can help. Once the certificate is installed, it will show as **Erised Test CA**. Please ensure it is marked as **_trusted_**.
144+
145+
You should now be able to run _erised_ in HTTPS mode by executing `erised -https -cert erised.crt -key erised.key` where _erised.crt_ is the "site's" (your computer) X.509 certificate and _erised.key_ is the private key.
146+
147+
### A word of caution about trusting certificates with unclear provenance:
148+
As mentioned before, covering the intricacies of establishing cryptographically secure digital identities and documenting the process to generate the relevant keys and certificates is well beyond the scope of this README, but it is important to at least call out some of the risks incurred when trusting a digital certificate because, in addition to validate identity and secure the communication between parties, they are also used to "sign" code (programs and libraries) that can run with privileged permissions.
149+
150+
I hope the message is clear: **when dealing with anything security related it always pays to be very careful and when in doubt, the best option is just not to.**
151+
152+
The [Secure Sockets Layer (SSL)](https://www.digicert.com/what-is-ssl-tls-and-https) certificates included with _erised_ are linked to _localhost_ and can only be used to enable TLS/SSL communication within your own computer.
153+
154+
For transparency, the (high level) steps to create them are:
155+
156+
1. Create a private key (_localCA.key_) to sign the Root CA certificate
157+
2. Generate a Root CA certificate (_localCA.pem_) signed with the above key
158+
3. Create a "site" private key (_erised.key_)
159+
4. Generate an intermediate Certificate Signing Request certificate (_erised.csr_) signed with site's private key
160+
5. Create an X.509 V3 certificate extension config file (_erised.ext_) to link the final certificate to _localhost_
161+
6. Generate the site's final certificate (_erised.crt_) using the Root CA certificate, the CA private key, the intermediate CSR certificate, and the certificate extension config file
162+
163+
Please note that neither of the private keys are password protected. This is definitely not something that you would normally do, but decided to simplify the process in case you'd want to tinker with the provided certs.
164+
131165
# Known Issues
132-
**erised** may be full of bugs. Poeple "_... have wasted away before it, not knowing if what they have seen is real, or even possible..._" so, use it with caution for it gives no knowledge or truth.
166+
_erised_ may be full of bugs. Poeple "_... have wasted away before it, not knowing if what they have seen is real, or even possible..._" so, use it with caution for it gives no knowledge or truth.
133167

134168
Of all of its deficiencies, the most notable is:
135-
* Using the _-path_ option could lead to significant security risks. When the _X-Erised-Response-File_ header is set it will search recursively for a matching filename in the current directory or **all** subdirectories underneath, returning the contents of the first match. For security reasons, path is restricted to the directory or subdirectories where the program was invoked.
136-
* https protocol is not yet supported
169+
* Using the _-path_ option could lead to significant security risks. When the _X-Erised-Response-File_ header is set, it will search recursively for a matching filename in the current directory or **all** subdirectories underneath it, returning the contents of the first match. For security reasons, path is restricted to the directory or subdirectories where the program was invoked.
137170

138-
I may or may not address these issues in a future release. Caveat Emptor
171+
I may or may not address this or any other issues in a future release. [**Caveat Emptor**](./LICENSE)
139172

140173
# Motivation
141174
When developing and testing REST API clients, sooner or later I'd come across situations where I needed a quick and easy way to dynamically test endpoint's responses under different scenarios. Although there are many excellent frameworks and mock servers available, the time and effort required to configure them is sometimes not justified, specially if the application under test exposes many routes, so after some brief and unsuccessful googling I decided to create my own.
142175

143-
**erised** was inspired by [Kenneth Reitz's](https://kennethreitz.org/) HTTP Request & Response Service [httpbin.io](https://httpbin.org/) and it may offer similar functionality in future releases.
176+
_erised_ was partially inspired by [Kenneth Reitz's](https://kennethreitz.org/) HTTP Request & Response Service [httpbin.io](https://httpbin.org/) and later on by Marchandise Rudy's [Echo-Server](https://github.com/Ealenn/Echo-Server).
144177

145178
The typical use case is to get a response to an arbitrary http request when your ability to control the server's behaviour is limited or non-existent.
146179

147-
Imagine you're developing some client for [api.chucknorris.io](https://api.chucknorris.io/) and want to test the **/jokes/random** path. You could certainly make live calls against the server:
180+
Imagine you're developing some client for [api.chucknorris.io](https://api.chucknorris.io/) and want to test the _/jokes/random_ path. You could certainly make live calls against the server:
148181
```sh
149182
curl -w '\n' -v -k https://api.chucknorris.io/jokes/random
150183
```
@@ -167,7 +200,7 @@ curl -w '\n' -v -k https://api.chucknorris.io/jokes/random
167200
* Closing connection 0
168201
```
169202
170-
**Or**, even better yet, you could use **erised** like this:
203+
**Or**, even better yet, you could use _erised_ like this:
171204
```sh
172205
curl -w '\n' -v \
173206
-H "X-Erised-Status-Code:OK" \

0 commit comments

Comments
 (0)