Skip to content

Commit 4897f6c

Browse files
authored
Merge pull request #249 from alan-turing-institute/248-server-did
Remove out-of-date `issuer_did` config parameter
2 parents 80f2759 + 0feceae commit 4897f6c

File tree

4 files changed

+123
-51
lines changed

4 files changed

+123
-51
lines changed

crates/trustchain-http/src/config.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,26 @@ const DEFAULT_PORT: u16 = 8081;
1616
/// HTTP configuration.
1717
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
1818
pub struct HTTPConfig {
19+
/// Hostname displayed in generated QR codes, e.g. for credential offers.
20+
/// If using a local server with an Android emulator for Trustchain Mobile development, the
21+
/// hostname `10.0.2.2` refers to `127.0.0.1` (localhost) of the machine running the emulator.
22+
pub host_display: String,
1923
/// Host address for server.
20-
/// machine running emulator.
2124
pub host: IpAddr,
22-
/// Hostname display in QR codes. For example, if using local server with an Android emulator
23-
/// `10.0.2.2` refers to `127.0.0.1` of machine
24-
/// running emulator.
25-
pub host_display: String,
26-
/// Port for server
25+
/// Port for server.
2726
pub port: u16,
28-
/// ION host
27+
/// ION host.
2928
pub ion_host: IpAddr,
30-
/// ION port
29+
/// ION port.
3130
pub ion_port: u16,
32-
/// Optional server DID if issuing or verifying
31+
/// Optional server DID if attesting dDIDs or verifying credentials/presentations.
3332
pub server_did: Option<String>,
34-
/// Flag indicating whether server uses https
33+
/// Flag indicating whether server uses https.
3534
pub https: bool,
36-
/// Path containing certificate and key necessary for https
35+
/// Path containing certificate and key necessary for https.
3736
pub https_path: Option<String>,
3837
/// Display downstream DIDs (instead of URLs) in QR codes for verifiable endpoint retrieval
39-
/// (`None` by default and unwrapped as `true`)
38+
/// (`None` by default and unwrapped as `true`).
4039
pub verifiable_endpoints: Option<bool>,
4140
/// Root event time for verifier.
4241
pub root_event_time: Option<Timestamp>,

docs/getting-started.md

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,27 +144,87 @@ Then open your copy of `trustchain_config.toml` for editing:
144144
```console
145145
nano $TRUSTCHAIN_CONFIG
146146
```
147-
and edit the following configuration parameters:
147+
This file is organised into different sections, separated by headings inside square brackets. At this point, we only need to consider the `[ion]` and `[cli]` sections.
148148

149-
- In the `[ion]` section, add the `bitcoin_rpc_username` and `bitcoin_rpc_password` that were chosen when you configured the [Bitcoin CLI](ion.md#bitcoin-cli).
150-
- If you intend to act as an issuer of digital credentials, and you already have you own DID for this purpose, add it in the `[http]` section to the `issuer_did` parameter value. Otherwise, the `[http]` section can be ignored.
151-
- If you know the root event time for your DID network, add it in the `[cli]` section to the `root_event_time` parameter value. This must be an integer in Unix time format, e.g.:
152-
```{ .text .no-copy }
153-
root_event_time = 1697213008
149+
Edit the following configuration parameters:
150+
151+
- In the `[ion]` section, set the `mongo_database_ion_core` parameter to either `"ion-mainnet-core"` or `"ion-testnet-core"`, depending on the Bitcoin network in use (see the example below). This parameter must match the `databaseName` parameter in the ION Core config file which can be viewed by running the following command:
152+
```console
153+
cat $ION_CORE_CONFIG_FILE_PATH
154154
```
155+
- Also in the `[ion]` section, set the address of your Bitcoin node in the `bitcoin_connection_string` parameter. If Bitcoin is running locally, set this to localhost and choose the correct port number for the particular Bitcoin network in use (see the example below).
156+
- Also in the `[ion]` section, set the `bitcoin_rpc_username` and `bitcoin_rpc_password` parameters that were chosen when you configured the [Bitcoin CLI](ion.md#bitcoin-cli).
157+
- If you know the root event time for your DID network, add it in the `[cli]` section to the `root_event_time` parameter value. This must be an integer in Unix time format.
158+
159+
After completing the above steps, the `trustchain_config.toml` file should look similar to the following example (choose the correct tab for your [Bitcoin network configuration](ion.md#bitcoin-mainnet-vs-testnet)):
160+
161+
=== "Mainnet"
162+
163+
```bash
164+
[ion]
165+
mongo_connection_string = "mongodb://localhost:27017/"
166+
mongo_database_ion_core = "ion-mainnet-core"
167+
168+
bitcoin_connection_string = "http://localhost:8332"
169+
bitcoin_rpc_username = "admin"
170+
bitcoin_rpc_password = "<YOUR_BITCOIN_RPC_PASSWORD>"
171+
172+
[cli]
173+
root_event_time = 1697213008
174+
ion_endpoint.host = "127.0.0.1"
175+
ion_endpoint.port = 3000
176+
```
177+
178+
=== "Testnet4"
179+
180+
```bash
181+
[ion]
182+
mongo_connection_string = "mongodb://localhost:27017/"
183+
mongo_database_ion_core = "ion-testnet-core"
184+
185+
bitcoin_connection_string = "http://localhost:48332"
186+
bitcoin_rpc_username = "admin"
187+
bitcoin_rpc_password = "<YOUR_BITCOIN_RPC_PASSWORD>"
188+
189+
[cli]
190+
root_event_time = 1769521645
191+
ion_endpoint.host = "127.0.0.1"
192+
ion_endpoint.port = 3000
193+
```
194+
195+
=== "Testnet3 (Deprecated)"
196+
197+
```bash
198+
[ion]
199+
mongo_connection_string = "mongodb://localhost:27017/"
200+
mongo_database_ion_core = "ion-testnet-core"
201+
202+
bitcoin_connection_string = "http://localhost:18332"
203+
bitcoin_rpc_username = "admin"
204+
bitcoin_rpc_password = "<YOUR_BITCOIN_RPC_PASSWORD>"
205+
206+
[cli]
207+
root_event_time = 1697213008
208+
ion_endpoint.host = "127.0.0.1"
209+
ion_endpoint.port = 3000
210+
```
155211

156212
!!! warning "Root event time"
157213

158214
The "root event time" refers to the exact time at which the root DID was published. It is imperative that this configuration parameter is entered correctly, because it identifies the root public key certificate.
159215

216+
The value given in the above example is for illustration only.
217+
160218
If you are not sure about the correct root event time for your network, or you are intending to create your own root DID, leave this parameter unset for now.
161219

162-
In future versions of Trustchain, this Unix time parameter will be replaced by a calendar date (the "root event date") plus a short confirmation code.
220+
In future versions of Trustchain, this Unix time parameter will be replaced by a calendar date, the "root event date", plus a short confirmation code (which is the format used in the Trustchain Mobile app).
163221

164222
## Using Trustchain
165223

166-
Trustchain is controlled via its command line interface (CLI). Supported operations include DID resolution, issuance, attestation and verification. It can also be used to issue and verify digital credentials.
224+
Trustchain is controlled via its command line interface (CLI). Supported operations include DID resolution, creation, attestation and verification. It can also be used to sign and verify digital credentials.
167225

168226
Instructions on how to use the Trustchain CLI are provided on the [Usage page](usage.md).
169227

228+
If you also want to be able to issue verifiable credentials to users of the Trustchain Mobile credential wallet app, check out [this page](http-server.md) for instructions on how to configure and run the built-in Trustchain HTTP server.
229+
170230
&nbsp;

docs/http-server.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,53 @@ Under the section headed `[http]`, add or edit the following configuration param
2626

2727
- Set the `root_event_time` parameter to the integer root DID timestamp for your network (in Unix Time).
2828
- Set the `host_display` parameter to the fully qualified domain name of your Trustchain HTTP server.
29+
- Set the `host` parameter to the host address for the server. If you want the server to be accessible only on a local network, set this to `"127.0.0.1"` (localhost). If you want the server to be accessible from the Internet, set it to `"0.0.0.0"`. In this case, ensure both your router and server are protected by a properly configured firewall.
2930
- Set the `port` parameter to the port number on which your server will listen for HTTP requests.
3031
- Set the `https` parameter to either `true` or `false`, depending on whether your server will use TLS for encrypted communications.
3132
- If `https` is set to `true`, set the `https_path` parameter to the directory containing the certificate and key necessary for accepting HTTPS connections. See the section on [HTTPS configuration](#https-configuration) for more details.
3233
- Set the `ion_host` parameter to the host name of your ION instance. If ION is running on the local machine, set this to the loopback address `"127.0.0.1"`.
3334
- Set the `ion_port` parameter to the port number of your ION instance. By default, ION listens on port `3000`.
34-
- If you intend to act as an issuer of digital credentials and you already have you own DID for this purpose, set it as the `server_did` parameter.
35+
- If you intend to use your server for credential verification and/or for dDID attestation (via the Trustchain challenge-response protocol), and you already have your own DID for this purpose, set it as the `server_did` parameter. If the server is only intended to respond to requests from the Trustchain Mobile app, e.g. for issuing verifiable credentials, this parameter is not required and can be omitted.
3536

3637
!!! example "Example HTTP server configuration"
3738

3839
After completing the above steps, the `[http]` section of `trustchain_config.toml` should look similar to the following example:
40+
3941
```bash
4042
[http]
41-
root_event_time = 1697213008
42-
host_display = "https://trustchain.example.com"
43+
root_event_time = 1769521645
44+
host_display = "<YOUR_SERVER_HOSTNAME>"
4345
port = 443
4446
https = true
4547
https_path = "~/.trustchain/http/self_signed_certs"
48+
host = "0.0.0.0"
4649
ion_host = "127.0.0.1"
4750
ion_port = 3000
48-
server_did = "did:ion:test:EiB4S2znMhXFMxLLuI6dSrcfn4uF1MLFGvMYTwRPRH_-eQ"
51+
server_did = "<YOUR_SERVER_DID>"
4952
```
5053

54+
### Network configuration
55+
56+
To make your Trustchain HTTP server reachable from the public Internet you will need to configure your local network to allow connections to the port given in the `trustchain_config.toml` file, and to route them to your Trustchain node.
57+
58+
If your Trustchain node is running on a virtual machine (VM) in the cloud, navigate to your cloud provider's web portal and open the network settings page for the VM. Then create an "inbound port rule" to allow incoming traffic to the relevant port.
59+
60+
If your node is running on a computer in your local network, the network configuration steps are as follows:
61+
62+
- On your router, configure the firewall to allow connections to the port configured for the Trustchain server, and configure port forwarding (for the same port) to the IP address of your Trustchain node on the local network. To enable this, you may want to assign a static local IP address to your Trustchain node.
63+
- If there is a firewall running on your Trustchain node, ensure it is configured to allow inbound connections to the relevant port.
64+
5165
### HTTPS configuration
5266

5367
It is strongly advisable to configure your Trustchain HTTP server to use TLS (Transport Layer Security) for encrypted communictions via HTTPS. This is done by setting the `https` config parameter to `true` and the `port` parameter to `443`, which is the default HTTPS port number.
5468

55-
In this case, you will need a TLS certificate and associated cryptographic keys.
69+
!!! info "HTTPS is required to support Trustchain Mobile"
70+
71+
The Trustchain HTTP server is designed to handle requests from the Trustchain Mobile app, for operations such as the issuance and verification of [Verifiable Credentials](https://www.w3.org/TR/vc-data-model-2.0/).
72+
73+
If you intend to use the HTTP server for this purpose, it is essential that you configure it with HTTPS support. The Trustchain Mobile app will refuse to connect to a server that does not have a valid TLS certificate.
74+
75+
To support HTTPS, you will need a TLS certificate and associated cryptographic keys.
5676

5777
If you do not already have a TLS certificate, you can obtain one by using a free and open source service called [Certbot](https://certbot.eff.org/). Certbot is a software tool for automatically generating [Let's Encrypt](https://letsencrypt.org/) certificates for web servers to enable HTTPS, which is precisely what is needed here.
5878

@@ -72,22 +92,22 @@ Step 7 of the Certbot instructions requires you to install your new TLS certific
7292

7393
- make a new directory to store the certificate:
7494
```console
75-
mkdir -p "$TRUSTCHAIN_CONFIG"/http/self_signed_certs
95+
mkdir -p "$TRUSTCHAIN_DATA"/http/self_signed_certs
7696
```
7797
- copy the certificate file `fullchain.pem` and the key file `privkey.pem` from the locations given in the output from Step 6 (above), to the new directory, e.g.:
7898
```console
79-
sudo cp /etc/letsencrypt/live/trustchain.example.com/fullchain.pem "$TRUSTCHAIN_CONFIG"/http/self_signed_certs
80-
sudo cp /etc/letsencrypt/live/trustchain.example.com/privkey.pem "$TRUSTCHAIN_CONFIG"/http/self_signed_certs
99+
sudo cp /etc/letsencrypt/live/trustchain.example.com/fullchain.pem "$TRUSTCHAIN_DATA"/http/self_signed_certs
100+
sudo cp /etc/letsencrypt/live/trustchain.example.com/privkey.pem "$TRUSTCHAIN_DATA"/http/self_signed_certs
81101
```
82102
- change the ownership of those files so they are owned by the user and group that will run the Trustchain server (replace `<USER>` and `<GROUP>` in the following commands):
83103
```console
84-
sudo chown <USER>:<GROUP> "$TRUSTCHAIN_CONFIG"/http/self_signed_certs/fullchain.pem
85-
sudo chown <USER>:<GROUP> "$TRUSTCHAIN_CONFIG"/http/self_signed_certs/privkey.pem
104+
sudo chown <USER>:<GROUP> "$TRUSTCHAIN_DATA"/http/self_signed_certs/fullchain.pem
105+
sudo chown <USER>:<GROUP> "$TRUSTCHAIN_DATA"/http/self_signed_certs/privkey.pem
86106
```
87107
- create symbolic links to the certificate and key files:
88108
```console
89-
ln -s "$TRUSTCHAIN_CONFIG"/http/self_signed_certs/fullchain.pem "$TRUSTCHAIN_CONFIG"/http/self_signed_certs/cert.pem
90-
ln -s "$TRUSTCHAIN_CONFIG"/http/self_signed_certs/privkey.pem "$TRUSTCHAIN_CONFIG"/http/self_signed_certs/key.pem
109+
ln -s "$TRUSTCHAIN_DATA"/http/self_signed_certs/fullchain.pem "$TRUSTCHAIN_DATA"/http/self_signed_certs/cert.pem
110+
ln -s "$TRUSTCHAIN_DATA"/http/self_signed_certs/privkey.pem "$TRUSTCHAIN_DATA"/http/self_signed_certs/key.pem
91111
```
92112

93113
!!! warning "Running the Trustchain HTTP server on port 443"
@@ -97,18 +117,6 @@ ln -s "$TRUSTCHAIN_CONFIG"/http/self_signed_certs/privkey.pem "$TRUSTCHAIN_CONFI
97117
sudo setcap CAP_NET_BIND_SERVICE=+eip $HOME/.cargo/bin/trustchain-http
98118
```
99119

100-
### Network configuration
101-
102-
To make your Trustchain HTTP server reachable from the public Internet you will need to configure your local network to allow connections to the port given in the `trustchain_config.toml` file, and to route them to your Trustchain node.
103-
104-
If your Trustchain node is running on a virtual machine (VM) in the cloud, navigate to your cloud provider's web portal and open the network settings page for the VM. Then create an "inbound port rule" to allow incoming traffic to the relevant port.
105-
106-
If your node is running on a computer in your local network, the network configuration steps are as follows:
107-
108-
- On your router, configure the firewall to allow connections to the port configured for the Trustchain server,
109-
- On your router, configure port forwarding (for the same port) to the IP address of your Trustchain node on the local network. To enable this, you may want to assign a static local IP address to your Trustchain node.
110-
- If there is a firewall running on your Trustchain node, ensure it is configured to allow connections to the relevant port.
111-
112120
## Running the HTTP server
113121

114122
Open a new Terminal window and invoke the Trustchain HTTP server with the following command:

trustchain_config.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
mongo_connection_string = "mongodb://localhost:27017/"
33
mongo_database_ion_core = "ion-testnet-core"
44

5-
bitcoin_connection_string = "http://localhost:18332"
5+
bitcoin_connection_string = "http://localhost:48332"
66
bitcoin_rpc_username = "<YOUR_BITCOIN_RPC_USERNAME>"
77
bitcoin_rpc_password = "<YOUR_BITCOIN_RPC_PASSWORD>"
88

9-
[http]
10-
host = "127.0.0.1"
11-
host_reference = "127.0.0.1"
12-
port = 8081
13-
issuer_did = "<YOUR_ISSUER_DID>"
14-
159
[cli]
1610
root_event_time = 0 # SET YOUR ROOT EVENT TIME HERE
1711
ion_endpoint.host = "127.0.0.1"
1812
ion_endpoint.port = 3000
13+
14+
[http]
15+
root_event_time = 0 # SET YOUR ROOT EVENT TIME HERE
16+
host_display = "<YOUR_SERVER_HOSTNAME>"
17+
host = "127.0.0.1"
18+
port = 80
19+
https = false
20+
https_path = "~/.trustchain/http/self_signed_certs"
21+
ion_host = "127.0.0.1"
22+
ion_port = 3000
23+
server_did = "<YOUR_SERVER_DID>"

0 commit comments

Comments
 (0)