Skip to content

Commit eddf08d

Browse files
authored
Merge pull request #67 from flashbots/peg/readme-demonstration
Add demonstration instructions to readme
2 parents ae560f0 + 7173d86 commit eddf08d

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Attestation exchange messages are formatted as follows:
121121

122122
SCALE is used by parity/substrate and was chosen because it is simple and actually matches the formatting used in TDX quotes. So it was already used as a dependency (via the [`dcap-qvl`](https://docs.rs/dcap-qvl) crate).
123123

124-
### Attestation Generation and Verification
124+
### Attestation Generation and Verification:
125125

126126
Attestation input takes the form of a 64 byte array.
127127

@@ -145,10 +145,82 @@ The `azure` feature, for Microsoft Azure attestation requires [tpm2](https://tpm
145145

146146
This feature is enabled by default. For non-azure deployments you can compile without this requirement by specifying `--no-default-features`. But note that this is will disable both generation and verification of azure attestations.
147147

148+
149+
## Trying it out locally (without CVM attestation)
150+
151+
This might help give an understanding of how it works.
152+
153+
1. Make sure you have the tpm2 dependency (see above) - or compile with `--no-default-features`.
154+
2. Run the helper script to generate a mock certifcate authority and a TLS certificate for localhost signed by it.
155+
156+
This requires `openssl` to be installed.
157+
158+
```
159+
./scripts/generate-cert.sh localhost 127.0.0.1
160+
```
161+
162+
3. Start a http server to try this out with, on 127.0.01:8000
163+
164+
This requires `python3` to be installed.
165+
166+
```
167+
python3 -m http.server 8000
168+
```
169+
170+
4. Start a proxy-server:
171+
172+
```
173+
cargo run -- server \
174+
--listen-addr 127.0.0.1:7000 \
175+
--server-attestation-type none \
176+
--allowed-remote-attestation-type none \
177+
--tls-private-key-path server.key \
178+
--tls-certificate-path server.crt \
179+
127.0.0.1:8000
180+
```
181+
182+
The final positional argument is the target address - in this case the python server we started in step 3.
183+
Note that you must specify that you accept 'none' as the remote attestation type.
184+
185+
5. Start a proxy-client:
186+
187+
```
188+
cargo run -- client \
189+
--listen-addr 127.0.0.1:6000 \
190+
--client-attestation-type none \
191+
--allowed-remote-attestation-type none \
192+
--tls-ca-certificate ca.crt \
193+
localhost:7000
194+
```
195+
196+
The final positional argument is the hostname and port of the proxy-server.
197+
Note that we specified a CA root of trust. If you use a standard certificate authority you do not need this argument.
198+
199+
6. Make a HTTP request to the proxy-client:
200+
201+
```
202+
curl 127.0.0.1:6000/README.md
203+
```
204+
205+
Assuming you started the python http server in the directory of this repository, this should print the contents of this README.
206+
207+
Since we just wanted to make a single GET request here, we can make this process simpler but using the `attested-get` command:
208+
209+
```
210+
cargo run -- attested-get \
211+
--url-path README.md
212+
--tls-ca-certificate ca.crt \
213+
--allowed-remote-attestation-type none \
214+
localhost:7000
215+
```
216+
217+
This should also print the README file. This should work even if the proxy-client from step 5 is not running.
218+
148219
## CLI differences from `cvm-reverse-proxy`
149220

150221
This aims to have a similar command line interface to `cvm-reverse-proxy` but there are some differences:
151222

152223
- The measurements file path is specified with `--measurements-file` rather than `--server-measurements` or `--client-measurements`.
153224
- If no measurements file is specified, `--allowed-remote-attestation-type` must be given.
154225
- `--log-dcap-quote` logs all attestation data (not only DCAP), but [currently] only remote attestation data, not locally-generated data.
226+

0 commit comments

Comments
 (0)