2021-11-24 18:37:46 +01:00
# SSL Certificate
2024-05-22 17:40:21 +02:00
2021-11-24 18:37:46 +01:00
## Why a certificate is important
2020-02-25 20:57:36 +01:00
Browsers require secure communication with the server to use camera API. Without it we can't use QR code scanning.
2024-05-22 17:40:21 +02:00
If you are running a VPS it's easy - you just [issue a new certificate ](./reverse-proxy.md#adding-https ) with Letsencrypt.
2020-02-25 20:57:36 +01:00
2021-02-10 09:42:25 +01:00
If you are only using the node at home and want to use it from your local network and via camera, you need to run it via SSL.
2020-02-25 20:57:36 +01:00
2021-11-24 18:37:46 +01:00
## Easy solution
2020-12-20 15:03:23 +01:00
The easiest solution is to simply add `--ssl` to the serve-command and the certificate will get created automatically in the specter-home-folder.
2024-05-22 17:40:21 +02:00
2020-12-20 15:03:23 +01:00
```
python3 -m cryptoadance.specter server --ssl
```
2021-11-24 18:37:46 +01:00
## Manual creation
2020-12-20 15:03:23 +01:00
2021-02-10 09:42:25 +01:00
A second way, which provides more customization, is to run the [`gen-certificate.sh` ](gen-certificate.sh ) script in this folder with your node's IP address as an argument:
2020-02-25 20:57:36 +01:00
```sh
2020-09-06 22:06:12 +02:00
gen-certificate.sh < your-node-local-ip-address >
2020-02-25 20:57:36 +01:00
```
It will create two files - `cert.pem` and `key.pem` .
2021-11-24 18:37:46 +01:00
### Bare Specter over HTTPS
2020-02-25 20:57:36 +01:00
Provide these files to Specter as arguments:
```sh
python -m cryptoadvance.specter server --cert=./cert.pem --key=./key.pem
```
2024-05-22 17:40:21 +02:00
_Note:_ Adding `--tor=your-tor-password` will create a tor hidden service with https.
2020-02-25 20:57:36 +01:00
2021-11-24 18:37:46 +01:00
### Specter with Nginx
2020-02-25 20:57:36 +01:00
Assuming you copied the files to `/etc/ssl/certs` and `/etc/ssl/private` add the following lines to server config (`/etc/nginx/sites-enabled/default` ):
```sh
listen 443 ssl http2;
ssl_certificate /etc/ssl/certs/cert.pem;
ssl_certificate_key /etc/ssl/private/key.pem;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
```
2021-02-10 09:42:25 +01:00
The config should look like this:
2020-02-25 20:57:36 +01:00
```
server{
listen 80 default_server;
listen 443 ssl http2;
2024-05-22 17:40:21 +02:00
2020-02-25 20:57:36 +01:00
server_name your_domain_or_ip;
ssl_certificate /etc/ssl/certs/cert.pem;
ssl_certificate_key /etc/ssl/private/key.pem;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
location / {
proxy_pass http://127.0.0.1:25441;
}
}
```
2021-11-24 18:37:46 +01:00
### Adding certificate to trusted
2020-02-25 20:57:36 +01:00
With these certificates you should be able to navigate to your node using https, but you will see a scary warning.
In Firefox you can still proceed to the website, in Chrome you can't unless you add `cert.pem` file to trusted (on the phone you still can).
On **Mac** : copy `cert.pem` to your computer, add it to your keychain and set `Trust` :
- Don't forget to quit Chrome
- Start the Keychain Access app and open the `Certificates` category
- Drag your certificate file onto the Keychain Access window
- Right-click on your certificate and unfold the `Trust` list
- In row `When using this certificate` , choose `Always Trust`
2020-12-20 15:03:23 +01:00
Other platforms: ???