summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs84
1 files changed, 84 insertions, 0 deletions
diff --git a/docs b/docs
new file mode 100644
index 0000000..68ced06
--- /dev/null
+++ b/docs
@@ -0,0 +1,84 @@
1
2nginx handles mtls, and allows connection to local gunicorn instance. If mTLS fails, connection fails and event is logged
3
4
5 ubuntu
6sudo pip install Flask gunicorn # to install for all users, especially www-data so that the service runs
7 nginx
8install nginx
9sudo systemctl enable --now nginx
10 # cat /var/log/nginx/access.log
11 # /etc/nginx/nginx.conf
12 gunicorn
13gunicorn --bind localhost:5000 app:app # for testing
14sudo nano /etc/systemd/system/gunicorn1.service # as a service
15sudo systemctl enable --now gunicorn1 # as a service
16 python
17app1.py
18sudo mkdir /var/www
19sudo chown -R www-data:www-data /var/www
20sudo cp app1.py /var/www
21
22
23 test
24# private key
25openssl genrsa -out ca.key 2048
26# public certificate
27openssl req -x509 -new -nodes -key ca.key -sha256 -days 1024 -out ca.pem -subj "/C=US/ST=YourState/L=YourCity/O=YourOrg/CN=YourCA"
28
29# server private key
30openssl genrsa -out server.key 2048
31# generate certificate signing request
32openssl req -new -key server.key -out server.csr -subj "/C=US/ST=YourState/L=YourCity/O=YourOrg/CN=localhost"
33# use public and private key of the ca to sign the cert signing request
34openssl x509 -req -in server.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out server.crt -days 365 -sha256
35
36openssl genrsa -out client.key 2048
37openssl req -new -key client.key -out client.csr -subj "/C=US/ST=YourState/L=YourCity/O=YourOrg/CN=client"
38openssl x509 -req -in client.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out client.crt -days 365 -sha256
39
40openssl genrsa -out wrong_client.key 2048
41openssl req -new -x509 -key wrong_client.key -out wrong_client.crt -days 365 -subj "/C=US/ST=State/L=City/O=Organization/CN=incorrectclient"
42
43curl https://127.0.0.1 --cacert ca.pem --cert wrong_client.crt --key wrong_client.key -k
44curl https://127.0.0.1 --cacert ca.pem --cert client.crt --key client.key -k
45
46
47 untested
48sudo cp /path/to/ca.pem /usr/local/share/ca-certificates/your-ca.crt
49sudo update-ca-certificates
50 nginx configuration
51 ocsp server to check that the server is valid
52 crl to check if a client is revoked
53server {
54 listen 443 ssl;
55 server_name yourdomain.com;
56
57 ssl_certificate /path/to/your/server.crt;
58 ssl_certificate_key /path/to/your/server.key;
59
60 # Client certificate verification
61 ssl_client_certificate /path/to/your/ca.pem;
62 ssl_verify_client on;
63
64 # Enable OCSP stapling and strict verification
65 ssl_stapling on;
66 ssl_stapling_verify on;
67 ssl_trusted_certificate /path/to/your/ca.pem;
68
69 # Specify resolver for OCSP stapling
70 resolver 8.8.8.8 8.8.4.4 valid=300s;
71 resolver_timeout 10s;
72
73 # Enforce OCSP response checking strictly
74 ssl_ocsp on;
75 ssl_ocsp_fail closed;
76
77 # Specify CRL file for client certificate revocation checking
78 ssl_crl /etc/nginx/ssl/crl.pem;
79
80 location / {
81 try_files $uri $uri/ =404;
82 }
83}
84