Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OCSP/CRL support #61

Merged
merged 56 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a460a99
Start adding support for the new ocsp helper
rambo Nov 14, 2023
e3b5752
trying to figure out actually working config for either OCSP or CRL
rambo Nov 15, 2023
fc1b750
update tags for cfssl and rmapi containers
rambo Nov 26, 2023
2194e45
Try to put HAProxy with CRL watched in front of webtak and COT to pre…
rambo Jan 27, 2024
d16d031
add missing network to rmapi
rambo Jan 27, 2024
c09cea2
call dump_crl also when calling ocsp refresh
rambo Jan 27, 2024
194b40b
enable CRL checking
rambo Jan 27, 2024
f3ed743
attempt to use caddy CRL refresh plugin
rambo Jan 27, 2024
f815e8a
fix typo, it does not do what we want though, TLS is terminated inste…
rambo Jan 27, 2024
c0934ce
do not attempt to haproxy tak traffic
rambo Jan 27, 2024
55bafbe
build custom nginx with inotify watcher for CRL
rambo Jan 28, 2024
4040e4a
use the nginx we build ourself
rambo Jan 28, 2024
a3ce13c
minor updates to productapi handling
rambo Jan 28, 2024
1287c4a
production side does not need long JWT lifetimes, mTLS is used
rambo Jan 28, 2024
29acef9
improvements to promoting and demoting users via takrmapi
rambo Jan 28, 2024
c2af697
we cannot both check mTLS cert validity and passthrough TLS at the sa…
rambo Jan 28, 2024
4d3ac8f
update submodule pointers
rambo Jan 29, 2024
2ca2a27
add healthcheck commands to rm api containers
rambo Jan 29, 2024
e8b44df
Add healthcheck endpoint to nginxes
rambo Jan 29, 2024
3806a53
healthcheck *MUST* exit with 1 (any nonzero code is not accepted) on …
rambo Jan 29, 2024
417aa21
auto-restart unhealthy containers (that have the autoheal label)
rambo Jan 29, 2024
fecf513
make productapi nginx use the same shared resource style as the others
rambo Jan 29, 2024
44014f5
update submodule pointers
rambo Jan 29, 2024
d5ea644
update deps (submodule pointers are to dep update commits)
rambo Jan 29, 2024
773a2a2
fix OCSP
rambo Feb 2, 2024
2302227
disable CRL since OCSP works, no need to keep reloading the process
rambo Feb 2, 2024
6f17e4a
enable OCSP for TAK
rambo Feb 3, 2024
2511ec6
add tak containers to the ocsp network, remove changes to takserver i…
rambo Feb 3, 2024
2f405c4
unify devel and production configs
rambo Feb 3, 2024
083c48b
make the resolver ip nginx requires configurable
rambo Feb 3, 2024
acfeaab
give takrmapi more time to start
rambo Feb 3, 2024
349605e
use ocsprest merged crl as the crl url
rambo Feb 5, 2024
7c0de8e
update submodule pointers
rambo Feb 7, 2024
4d8b39c
add ENV variables for public OCSP responder URL
rambo Feb 9, 2024
5c54784
improve healthchecks
rambo Feb 10, 2024
c048e1e
increase timeouts since signing certs is slower now
rambo Feb 10, 2024
e6e15ed
need trailing slashes for correct proxy_pass behaviour
rambo Feb 11, 2024
fbaa921
update submodules
rambo Feb 11, 2024
5158044
Make it easy to switch TILAUSPALVELU domain via ENV
rambo Feb 13, 2024
59d8ad8
Make sure the healthchecks return code 1 on failue, docker compose ha…
rambo Feb 26, 2024
5cf9897
new main pointers for all submodules
rambo Mar 1, 2024
16c172c
fix tests dep version conflict
rambo Mar 1, 2024
37c7574
Fix missed merge conflict
rambo Mar 1, 2024
1c34e6f
bump versions of the containers, sadly they do not match versioning i…
rambo Mar 1, 2024
a8e61cd
API was changed to not return approvecodes
rambo Mar 1, 2024
e58f64f
add versioning to the tak and nginx tags as well so we do not acciden…
rambo Mar 2, 2024
0fb9035
new main pointers for ui and takintegration
rambo Mar 11, 2024
5ca6154
we must not have a trailing slash in the ocsp proxy url
rambo Mar 19, 2024
87c4506
we need to support both POST to /ca/oscp without trailing slash and g…
rambo Mar 19, 2024
9f06336
enable OCSP checking for the product API nginxen as well
rambo Mar 19, 2024
0cd070c
ocsprest component updated
rambo Mar 23, 2024
c6993bc
update RMapi to 1.3.1
rambo Mar 23, 2024
852f94d
update RMapi to 1.3.2
rambo Mar 23, 2024
50b6e70
update ocsprest to 1.0.3
rambo Mar 23, 2024
e2ea904
do not give .git to docker context
rambo Mar 23, 2024
858b53a
update takintegration actually to 1.1.0, give the correct takserver i…
rambo Mar 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ coverage*
*.exe
build/

# docker build files (so just changing them does not invalidate *all* caches)
# docker build files and git state (so just changing them does not invalidate *all* caches)
.dockerignore
Dockerfile
.git
7 changes: 7 additions & 0 deletions caddy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM caddy:builder AS builder
RUN xcaddy build \
--with github.com/gr33nbl00d/caddy-revocation-validator \
&& true

FROM caddy:latest as production
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
93 changes: 93 additions & 0 deletions caddy/templates_rasenmaeher/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
}

# Regular HTTPS Server Block (non-mTLS)
${NGINX_HOST} {
# Redirect HTTP to HTTPS
redir https://${host}${uri} permanent

# HTTPS configuration
tls /le_certs/${NGINX_CERT_NAME}/fullchain.pem /le_certs/${NGINX_CERT_NAME}/privkey.pem

# Proxy locations
route /ca/crl {
reverse_proxy ${NGINX_UPSTREAM}:${NGINX_UPSTREAM_PORT}/api/v1/utils/crl
}

route /ca/ocsp {
reverse_proxy ${NGINX_OCSP_UPSTREAM}:${CFSSL_OCSP_BIND_PORT}
}

route /api/* {
reverse_proxy ${NGINX_UPSTREAM}:${NGINX_UPSTREAM_PORT}/api
}

# Static file serving
file_server {
root /rmui_files
index index.html
}
}

# mTLS Server Block
mtls.${NGINX_HOST} {
# Redirect HTTP to HTTPS
redir https://${host}${uri} permanent

# HTTPS configuration
tls /le_certs/${NGINX_CERT_NAME}/fullchain.pem /le_certs/${NGINX_CERT_NAME}/privkey.pem

"client_authentication": {
"trusted_ca_certs_pem_files": [
"/ca_public/ca_chain.pem"
],
"mode": "require_and_verify",
"verifiers": [ {
"verifier": "revocation",
"mode": "crl_only",
"crl_config": {
"work_dir": "./crlworkdir",
"storage_type": "memory",
"update_interval": "1m",
"signature_validation_mode": "verify",
"crl_files" : ["/ca_public/crl.pem"],
crl_urls: ["http://${NGINX_UPSTREAM}:${NGINX_UPSTREAM_PORT}/api/v1/utils/crl"]
"cdp_config": {
"crl_fetch_mode": "fetch_actively",
"crl_cdp_strict": true
}
}
}
]
}

# Proxy locations
route /ca/* {
redir https://${NGINX_HOST}:${NGINX_HTTPS_PORT}{uri}
}

route /api/* {
handle {
@mtls_fail expression {ssl_client_verify} != "SUCCESS"
redir @mtls_fail https://${NGINX_HOST}:${NGINX_HTTPS_PORT}/error?code=mtls_fail
}

reverse_proxy ${NGINX_UPSTREAM}:${NGINX_UPSTREAM_PORT}/api
#header_upstream X-ClientCert-DN {>X-ClientCert-DN}
#header_upstream X-ClientCert-Serial {>X-ClientCert-Serial}
}

# Static file serving with mTLS check
route {
handle {
@mtls_fail expression {ssl_client_verify} != "SUCCESS"
redir @mtls_fail https://${NGINX_HOST}:${NGINX_HTTPS_PORT}/error?code=mtls_fail
}

file_server {
root /rmui_files
index index.html
try_files {path} {path}/ /index.html
}
}
}
28 changes: 23 additions & 5 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# This extends the _local file, run with:
# `docker-compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml up -d`
version: '3.7'

x-nginxbuilds: &nginxbuildinfo
image: pvarki/nginx:1.25
build:
context: ./nginx
dockerfile: Dockerfile


services:
rmapi:
image: pvarki/rmapi:devel_shell${DOCKER_TAG_EXTRA:-}
Expand All @@ -9,6 +17,12 @@ services:
dockerfile: Dockerfile
target: devel_shell
command: ["-c", "source /root/.profile && poetry install && uvicorn --host 0.0.0.0 --port 8000 --log-level debug --factory rasenmaeher_api.web.application:get_app --reload"]
healthcheck:
test: '/bin/bash -c "source /root/.profile && rasenmaeher_api healthcheck" || exit 1'
interval: 5s
timeout: 5s
retries: 3
start_period: 5s
volumes:
- "./api:/app"

Expand Down Expand Up @@ -36,7 +50,7 @@ services:
start_period: 5s

rmnginx: # need to load different templates for uidev
image: nginx:stable
<<: *nginxbuildinfo
environment:
NGINX_UI_UPSTREAM: "rmuidev"
NGINX_UI_UPSTREAM_PORT: ${NGINX_UI_UPSTREAM_PORT:-8002}
Expand Down Expand Up @@ -71,7 +85,7 @@ services:
condition: service_healthy

fpnginx: # apparently we have to specify these here or it tries to start too early
image: nginx:stable
<<: *nginxbuildinfo
depends_on:
rmfpapi:
condition: service_healthy
Expand All @@ -84,16 +98,20 @@ services:
dockerfile: Dockerfile
target: integ_devel_shell
command: ["-c", "source /root/.profile && /container-init.sh && poetry install && uvicorn --host 0.0.0.0 --port 8003 --log-level debug --factory takrmapi.app:get_app --reload"]
environment:
LOG_LEVEL: 10
volumes:
- "./takintegration:/app"
healthcheck:
test: '/bin/bash -c "source /root/.profile && takrmapi healthcheck" || exit 1'
interval: 5s
timeout: 5s
retries: 3
start_period: 5s
depends_on:
rmnginx:
condition: service_healthy

taknginx: # apparently we have to specify these here or it tries to start too early
image: nginx:stable
<<: *nginxbuildinfo
depends_on:
takrmapi:
condition: service_healthy
Expand Down
Loading
Loading