diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 0048cab..7d1fbd4 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -41,3 +41,39 @@ jobs: push: true pull: true tags: ${{ steps.meta.outputs.tags }} + + build_and_push_ocsp_image: + name: "Build and push OCSP image" + runs-on: hostinger + steps: + - name: Checkout sources + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Gitea container registry + uses: docker/login-action@v3 + with: + registry: gitea.woggioni.net + username: woggioni-opencode-agent + password: ${{ secrets.PUBLISHER_TOKEN }} + - name: Extract metadata for OCSP image tags + id: meta + uses: docker/metadata-action@v5 + with: + images: gitea.woggioni.net/woggioni/kca-ocsp + flavor: latest=false + tags: | + type=match,pattern=release/(.*),group=1 + type=raw,value=latest + - name: Build and push OCSP image + uses: docker/build-push-action@v6 + with: + context: . + builder: multiplatform-builder + file: ocsp-responder/Dockerfile + platforms: linux/amd64 + push: true + pull: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/README.md b/README.md index c609a1d..874fa20 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,9 @@ bucket and ships a standalone Rust/Axum responder on port `2560`. concurrent requests cause at most one S3 `GetObject` per CA per second. - If S3 is unavailable, a stale snapshot is served within the configured grace period; otherwise the responder returns `tryLater`. +- Gitea Actions publishes `gitea.woggioni.net/woggioni/kca-ocsp` on the same + `release/*` tags as the server image. The responder image is a statically + linked musl executable running `FROM scratch` with only the CA bundle. Enable publishing in KCA with `KCA_OCSP_S3_BUCKET` and the other `KCA_OCSP_*` variables in `server/.env.example`. Run the responder with a diff --git a/docker-compose.yml b/docker-compose.yml index e1afe99..3256327 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -125,6 +125,7 @@ services: # docker compose --profile ocsp up --build ocsp: profiles: ["ocsp"] + image: gitea.woggioni.net/woggioni/kca-ocsp:${OCSP_IMAGE_TAG:-latest} build: context: . dockerfile: ocsp-responder/Dockerfile diff --git a/ocsp-responder/Cargo.lock b/ocsp-responder/Cargo.lock index 873e688..3120c1f 100644 --- a/ocsp-responder/Cargo.lock +++ b/ocsp-responder/Cargo.lock @@ -60,8 +60,6 @@ checksum = "939e256cfe0ed68e96d32f194339d88210d5c10685cff0787400158f852c6819" dependencies = [ "aws-credential-types", "aws-runtime", - "aws-sdk-sso", - "aws-sdk-ssooidc", "aws-sdk-sts", "aws-smithy-async", "aws-smithy-http", @@ -73,14 +71,11 @@ dependencies = [ "aws-types", "bytes", "fastrand", - "hex", "http 1.5.0", - "sha1 0.10.7", "time", "tokio", "tracing", "url", - "zeroize", ] [[package]] @@ -95,29 +90,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "aws-lc-rs" -version = "1.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faac5829c2b74c28f830747e7818ccfb684261b5f48a1118b1e2a13d36dfab13" -dependencies = [ - "aws-lc-sys", - "zeroize", -] - -[[package]] -name = "aws-lc-sys" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1622d8446a2d4b2ce0c7eefc73dd43a99779028d5ee5c2dd8073a658ba8a2bc" -dependencies = [ - "cc", - "cmake", - "dunce", - "fs_extra", - "pkg-config", -] - [[package]] name = "aws-runtime" version = "1.10.2" @@ -180,56 +152,6 @@ dependencies = [ "url", ] -[[package]] -name = "aws-sdk-sso" -version = "1.117.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316813498fa9c403877007934ae448aa44b18136f58051f8fa3c5b79b44bdc6" -dependencies = [ - "arc-swap", - "aws-credential-types", - "aws-runtime", - "aws-smithy-async", - "aws-smithy-http", - "aws-smithy-json", - "aws-smithy-observability", - "aws-smithy-runtime", - "aws-smithy-runtime-api", - "aws-smithy-schema", - "aws-smithy-types", - "aws-types", - "bytes", - "fastrand", - "http 1.5.0", - "regex-lite", - "tracing", -] - -[[package]] -name = "aws-sdk-ssooidc" -version = "1.119.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31db35e5662787b786daba15f431e4393c7ea512b70fa112bd048d1f3ecf877a" -dependencies = [ - "arc-swap", - "aws-credential-types", - "aws-runtime", - "aws-smithy-async", - "aws-smithy-http", - "aws-smithy-json", - "aws-smithy-observability", - "aws-smithy-runtime", - "aws-smithy-runtime-api", - "aws-smithy-schema", - "aws-smithy-types", - "aws-types", - "bytes", - "fastrand", - "http 1.5.0", - "regex-lite", - "tracing", -] - [[package]] name = "aws-sdk-sts" version = "1.122.0" @@ -268,19 +190,14 @@ dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", "bytes", - "crypto-bigint 0.5.5", - "ecdsa 0.17.0", "form_urlencoded", "hex", "hmac 0.13.0", "http 1.5.0", - "p256 0.14.0", "percent-encoding", "sha2 0.11.1", - "subtle", "time", "tracing", - "zeroize", ] [[package]] @@ -359,21 +276,13 @@ dependencies = [ "h2 0.3.27", "h2 0.4.20", "http 0.2.12", - "http 1.5.0", "http-body 0.4.6", "hyper 0.14.32", - "hyper 1.12.0", - "hyper-rustls 0.24.2", - "hyper-rustls 0.27.10", - "hyper-util", + "hyper-rustls", "pin-project-lite", - "rustls 0.21.12", - "rustls 0.23.46", + "rustls", "rustls-native-certs", - "rustls-pki-types", "tokio", - "tokio-rustls 0.26.6", - "tower", "tracing", ] @@ -583,24 +492,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base16ct" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" - [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" - [[package]] name = "base64-simd" version = "0.8.0" @@ -670,8 +567,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877bf67ac8e52449eb2f9e98a344ea163beb70dd1f9eebe3cc5357dcfeaee4df" dependencies = [ "find-msvc-tools", - "jobserver", - "libc", "shlex", ] @@ -695,15 +590,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "cmake" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" -dependencies = [ - "cc", -] - [[package]] name = "cmov" version = "0.5.4" @@ -738,12 +624,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "cpubits" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" - [[package]] name = "cpufeatures" version = "0.2.17" @@ -788,23 +668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-bigint" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271" -dependencies = [ - "cpubits", - "ctutils", - "getrandom 0.4.3", - "hybrid-array", - "num-traits", - "rand_core 0.10.1", + "rand_core", "subtle", "zeroize", ] @@ -825,9 +689,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ - "getrandom 0.4.3", "hybrid-array", - "rand_core 0.10.1", ] [[package]] @@ -837,7 +699,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d28fb6aa7dd680b3ffd1a3e64e115c177bdba63c0ae7f9cd48129ff05c4fa0" dependencies = [ "cmov", - "subtle", ] [[package]] @@ -849,18 +710,7 @@ dependencies = [ "const-oid 0.9.6", "der_derive", "flagset", - "pem-rfc7468 0.7.0", - "zeroize", -] - -[[package]] -name = "der" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a" -dependencies = [ - "const-oid 0.10.2", - "pem-rfc7468 1.0.0", + "pem-rfc7468", "zeroize", ] @@ -916,39 +766,18 @@ dependencies = [ "syn 3.0.9", ] -[[package]] -name = "dunce" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" - [[package]] name = "ecdsa" version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der 0.7.10", + "der", "digest 0.10.7", - "elliptic-curve 0.13.8", - "rfc6979 0.4.0", - "signature 2.2.0", - "spki 0.7.3", -] - -[[package]] -name = "ecdsa" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0681a4fc24c767085329728d8dfba959af91228aa4610cca4f8ce317ba46ae0" -dependencies = [ - "der 0.8.2", - "digest 0.11.3", - "elliptic-curve 0.14.1", - "rfc6979 0.6.0", - "signature 3.0.0", - "spki 0.8.1", - "zeroize", + "elliptic-curve", + "rfc6979", + "signature", + "spki", ] [[package]] @@ -963,37 +792,16 @@ version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.5", + "base16ct", + "crypto-bigint", "digest 0.10.7", - "ff 0.13.1", + "ff", "generic-array", - "group 0.13.0", - "pem-rfc7468 0.7.0", - "pkcs8 0.10.2", - "rand_core 0.6.4", - "sec1 0.7.3", - "subtle", - "zeroize", -] - -[[package]] -name = "elliptic-curve" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d65aa39b3a5c1c9c1b745c9a019234bb7a21b77abcb4f4d266d706e2d577d65" -dependencies = [ - "base16ct 1.0.0", - "crypto-bigint 0.7.5", - "crypto-common 0.2.2", - "digest 0.11.3", - "ff 0.14.0", - "group 0.14.0", - "hybrid-array", - "pem-rfc7468 1.0.0", - "pkcs8 0.11.0", - "rand_core 0.10.1", - "sec1 0.8.1", + "group", + "pem-rfc7468", + "pkcs8", + "rand_core", + "sec1", "subtle", "zeroize", ] @@ -1026,17 +834,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "ff" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f" -dependencies = [ - "rand_core 0.10.1", + "rand_core", "subtle", ] @@ -1073,12 +871,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - [[package]] name = "futures-channel" version = "0.3.34" @@ -1140,37 +932,14 @@ dependencies = [ "wasi", ] -[[package]] -name = "getrandom" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "rand_core 0.10.1", -] - [[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff 0.13.1", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "group" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4" -dependencies = [ - "ff 0.14.0", - "rand_core 0.10.1", + "ff", + "rand_core", "subtle", ] @@ -1318,9 +1087,7 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" dependencies = [ - "subtle", "typenum", - "zeroize", ] [[package]] @@ -1355,9 +1122,7 @@ checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" dependencies = [ "atomic-waker", "bytes", - "futures-channel", "futures-core", - "h2 0.4.20", "http 1.5.0", "http-body 1.1.0", "httparse", @@ -1366,7 +1131,6 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", - "want", ] [[package]] @@ -1379,25 +1143,9 @@ dependencies = [ "http 0.2.12", "hyper 0.14.32", "log", - "rustls 0.21.12", + "rustls", "tokio", - "tokio-rustls 0.24.1", -] - -[[package]] -name = "hyper-rustls" -version = "0.27.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" -dependencies = [ - "http 1.5.0", - "hyper 1.12.0", - "hyper-util", - "rustls 0.23.46", - "rustls-native-certs", - "tokio", - "tokio-rustls 0.26.6", - "tower-service", + "tokio-rustls", ] [[package]] @@ -1406,22 +1154,13 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" dependencies = [ - "base64 0.23.1", "bytes", - "futures-channel", - "futures-util", "http 1.5.0", "http-body 1.1.0", - "httparse", "hyper 1.12.0", - "ipnet", - "libc", - "percent-encoding", "pin-project-lite", - "socket2 0.6.5", "tokio", "tower-service", - "tracing", ] [[package]] @@ -1562,28 +1301,12 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "ipnet" -version = "2.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" - [[package]] name = "itoa" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" -[[package]] -name = "jobserver" -version = "0.1.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" -dependencies = [ - "getrandom 0.4.3", - "libc", -] - [[package]] name = "js-sys" version = "0.3.106" @@ -1603,17 +1326,17 @@ dependencies = [ "aws-config", "aws-sdk-s3", "axum", - "base64 0.22.1", + "base64", "bytes", "chrono", "const-oid 0.9.6", - "der 0.7.10", - "ecdsa 0.16.9", + "der", + "ecdsa", "hex", - "p256 0.13.2", - "pkcs8 0.10.2", + "p256", + "pkcs8", "rsa", - "sec1 0.7.3", + "sec1", "serde", "serde_json", "serde_yaml", @@ -1811,25 +1534,12 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" dependencies = [ - "ecdsa 0.16.9", - "elliptic-curve 0.13.8", - "primeorder 0.13.6", + "ecdsa", + "elliptic-curve", + "primeorder", "sha2 0.10.9", ] -[[package]] -name = "p256" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c9239b2dbc807adbbe147e8cf72ea7450c3a0aabe62cb8e75ff4ec22e1f72a" -dependencies = [ - "ecdsa 0.17.0", - "elliptic-curve 0.14.1", - "primefield", - "primeorder 0.14.0", - "sha2 0.11.1", -] - [[package]] name = "parking_lot" version = "0.12.5" @@ -1862,15 +1572,6 @@ dependencies = [ "base64ct", ] -[[package]] -name = "pem-rfc7468" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.2" @@ -1889,9 +1590,9 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ - "der 0.7.10", - "pkcs8 0.10.2", - "spki 0.7.3", + "der", + "pkcs8", + "spki", ] [[package]] @@ -1900,26 +1601,10 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.10", - "spki 0.7.3", + "der", + "spki", ] -[[package]] -name = "pkcs8" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" -dependencies = [ - "der 0.8.2", - "spki 0.8.1", -] - -[[package]] -name = "pkg-config" -version = "0.3.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" - [[package]] name = "potential_utf" version = "0.1.6" @@ -1944,40 +1629,13 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "primefield" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c555a6e4eb7d4e158fcb028c835c3b8642206ddc279b5c6b202ef9a8bdb592f4" -dependencies = [ - "crypto-bigint 0.7.5", - "crypto-common 0.2.2", - "ff 0.14.0", - "rand_core 0.10.1", - "subtle", - "zeroize", -] - [[package]] name = "primeorder" version = "0.13.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" dependencies = [ - "elliptic-curve 0.13.8", -] - -[[package]] -name = "primeorder" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c9f42978c78a00e3d68f69fc03e57a234debae69da4020a4fb588fcdcd07b06" -dependencies = [ - "elliptic-curve 0.14.1", - "once_cell", - "primefield", - "serdect", - "wnaf", + "elliptic-curve", ] [[package]] @@ -1998,12 +1656,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" - [[package]] name = "rand" version = "0.8.8" @@ -2011,7 +1663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" dependencies = [ "rand_chacha", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -2021,7 +1673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -2030,15 +1682,9 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.17", + "getrandom", ] -[[package]] -name = "rand_core" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" - [[package]] name = "redox_syscall" version = "0.5.18" @@ -2081,16 +1727,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "rfc6979" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b" -dependencies = [ - "crypto-bigint 0.7.5", - "hmac 0.13.0", -] - [[package]] name = "ring" version = "0.17.14" @@ -2099,7 +1735,7 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.17", + "getrandom", "libc", "untrusted", "windows-sys 0.52.0", @@ -2117,11 +1753,11 @@ dependencies = [ "num-integer", "num-traits", "pkcs1", - "pkcs8 0.10.2", - "rand_core 0.6.4", + "pkcs8", + "rand_core", "sha2 0.10.9", - "signature 2.2.0", - "spki 0.7.3", + "signature", + "spki", "subtle", "zeroize", ] @@ -2143,24 +1779,10 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", - "rustls-webpki 0.101.7", + "rustls-webpki", "sct", ] -[[package]] -name = "rustls" -version = "0.23.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" -dependencies = [ - "aws-lc-rs", - "once_cell", - "rustls-pki-types", - "rustls-webpki 0.103.16", - "subtle", - "zeroize", -] - [[package]] name = "rustls-native-certs" version = "0.8.5" @@ -2192,18 +1814,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustls-webpki" -version = "0.103.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" -dependencies = [ - "aws-lc-rs", - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.23" @@ -2247,24 +1857,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "base16ct 0.2.0", - "der 0.7.10", + "base16ct", + "der", "generic-array", - "pkcs8 0.10.2", - "subtle", - "zeroize", -] - -[[package]] -name = "sec1" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56d437c2f19203ce5f7122e507831de96f3d2d4d3be5af44a0b0a09d8a80e4d" -dependencies = [ - "base16ct 1.0.0", - "ctutils", - "der 0.8.2", - "hybrid-array", + "pkcs8", "subtle", "zeroize", ] @@ -2377,16 +1973,6 @@ dependencies = [ "unsafe-libyaml", ] -[[package]] -name = "serdect" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e" -dependencies = [ - "base16ct 1.0.0", - "serde", -] - [[package]] name = "sha1" version = "0.10.7" @@ -2463,17 +2049,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "signature" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" -dependencies = [ - "digest 0.11.3", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -2527,17 +2103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.10", -] - -[[package]] -name = "spki" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9" -dependencies = [ - "base64ct", - "der 0.8.2", + "der", ] [[package]] @@ -2715,17 +2281,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.12", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.26.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" -dependencies = [ - "rustls 0.23.46", + "rustls", "tokio", ] @@ -3134,18 +2690,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "wnaf" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795ca18b3fdb5e62bf982199278341ddcf7ebf7d32e25e212ad05d496e95f6fa" -dependencies = [ - "ff 0.14.0", - "group 0.14.0", - "hybrid-array", - "primefield", -] - [[package]] name = "writeable" version = "0.6.4" @@ -3159,8 +2703,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1301e935010a701ae5f8655edc0ad17c44bad3ac5ce8c39185f75453b720ae94" dependencies = [ "const-oid 0.9.6", - "der 0.7.10", - "spki 0.7.3", + "der", + "spki", "tls_codec", ] @@ -3171,11 +2715,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e54e695a31f0fecb826cf59ae2093c941d7ef932a1f8508185dd23b29ce2e2e" dependencies = [ "const-oid 0.9.6", - "der 0.7.10", + "der", "digest 0.10.7", - "rand_core 0.6.4", - "signature 2.2.0", - "spki 0.7.3", + "rand_core", + "signature", + "spki", "x509-cert", ] diff --git a/ocsp-responder/Cargo.toml b/ocsp-responder/Cargo.toml index 996ed60..d734372 100644 --- a/ocsp-responder/Cargo.toml +++ b/ocsp-responder/Cargo.toml @@ -30,5 +30,14 @@ ecdsa = { version = "0.16", features = ["der"] } pkcs8 = { version = "0.10", features = ["pem"] } x509-ocsp = { version = "0.2.1", features = ["builder", "std"] } x509-cert = { version = "0.2", features = ["std"] } -aws-config = "1" -aws-sdk-s3 = "1" +aws-config = { version = "1", default-features = false, features = [ + "behavior-version-latest", + "credentials-process", + "legacy-client", + "rt-tokio", +] } +aws-sdk-s3 = { version = "1", default-features = false, features = [ + "http-1x", + "legacy-https-client", + "rt-tokio", +] } diff --git a/ocsp-responder/Dockerfile b/ocsp-responder/Dockerfile index a3b32ea..0154fc2 100644 --- a/ocsp-responder/Dockerfile +++ b/ocsp-responder/Dockerfile @@ -1,29 +1,41 @@ # syntax=docker/dockerfile:1 -# Standalone Rust/Axum OCSP responder. It has no database or KCA master-key -# access; configuration and signer material are mounted at runtime. +# Standalone Rust/Axum OCSP responder. +# +# The final image is scratch: the binary is a statically linked musl +# executable and the only file besides it is the CA bundle needed for +# outbound HTTPS to S3. Configuration, CA certificates and delegated signer +# material are mounted at runtime. + +FROM rust:1-alpine AS builder + +RUN apk add --no-cache build-base musl-dev perl ca-certificates file binutils \ + && rustup target add x86_64-unknown-linux-musl -FROM rust:1-slim-bookworm AS builder WORKDIR /app COPY ocsp-responder/Cargo.toml ocsp-responder/Cargo.lock ./ COPY ocsp-responder/src ./src + RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/app/target \ - cargo build --release --locked \ - && cp /app/target/release/kca-ocsp-responder /usr/local/bin/kca-ocsp-responder + RUSTFLAGS="-C target-feature=+crt-static" \ + cargo build --release --locked --target x86_64-unknown-linux-musl \ + && strip target/x86_64-unknown-linux-musl/release/kca-ocsp-responder \ + && file target/x86_64-unknown-linux-musl/release/kca-ocsp-responder \ + | grep -Eq "statically linked|static-pie linked" \ + && cp target/x86_64-unknown-linux-musl/release/kca-ocsp-responder /kca-ocsp-responder + +FROM scratch -FROM debian:bookworm-slim -RUN addgroup --system ocsp \ - && adduser --system --ingroup ocsp --no-create-home ocsp \ - && mkdir -p /etc/ssl/certs COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +COPY --from=builder /kca-ocsp-responder /kca-ocsp-responder -COPY --from=builder /usr/local/bin/kca-ocsp-responder /usr/local/bin/kca-ocsp-responder +ENV OCSP_CONFIG=/etc/ocsp/responder.yaml \ + SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt -ENV OCSP_CONFIG=/etc/ocsp/responder.yaml -USER ocsp +USER 65532:65532 EXPOSE 2560 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \ - CMD ["/usr/local/bin/kca-ocsp-responder", "--healthcheck"] + CMD ["/kca-ocsp-responder", "--healthcheck"] -CMD ["/usr/local/bin/kca-ocsp-responder"] +ENTRYPOINT ["/kca-ocsp-responder"] diff --git a/ocsp-responder/README.md b/ocsp-responder/README.md index ce69740..138e1aa 100644 --- a/ocsp-responder/README.md +++ b/ocsp-responder/README.md @@ -30,8 +30,8 @@ responder never infers status from a partial revoked-only list. 1. Create a config based on `responder.example.yaml`. 2. Put your CA certificates and delegated signer files where the config points. 3. Export standard AWS credentials / endpoint variables as needed. -4. Make the signer key readable by the container user (`ocsp`, uid/gid - `100:101` in the provided image), or mount it via a Docker secret. +4. Make the signer key readable by the container user (`65532:65532` in the + published scratch image), or mount it via a Docker secret. 5. Run: ```sh @@ -40,6 +40,21 @@ OCSP_CONFIG=./responder.yaml cargo run The default listen address is `0.0.0.0:2560`. +The published image is built by Gitea Actions on `release/*` tags: + +```sh +docker run --rm -p 2560:2560 \ + -v "$PWD/responder.yaml:/etc/ocsp/responder.yaml:ro" \ + -v "$PWD/ca:/etc/ocsp/ca:ro" \ + -v "$PWD/signers:/etc/ocsp/signers:ro" \ + -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY \ + gitea.woggioni.net/woggioni/kca-ocsp:latest +``` + +It runs `FROM scratch` and contains only a statically linked musl executable +and a CA bundle for outbound S3 HTTPS. There is no shell or package manager in +the image. + ## Verify with OpenSSL For a CA certificate `ca.crt` and leaf certificate `leaf.crt`: diff --git a/ocsp-responder/src/main.rs b/ocsp-responder/src/main.rs index 29b70d1..3020d10 100644 --- a/ocsp-responder/src/main.rs +++ b/ocsp-responder/src/main.rs @@ -75,7 +75,18 @@ async fn health() -> &'static str { fn healthcheck() -> Result<(), Box> { use std::io::{Read, Write}; - let mut stream = std::net::TcpStream::connect("127.0.0.1:2560")?; + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + let config = config::load_config()?; + let host = if config.listen.ip().is_unspecified() { + match config.listen.ip() { + IpAddr::V4(_) => IpAddr::V4(Ipv4Addr::LOCALHOST), + IpAddr::V6(_) => IpAddr::V6(std::net::Ipv6Addr::LOCALHOST), + } + } else { + config.listen.ip() + }; + let socket = SocketAddr::new(host, config.listen.port()); + let mut stream = std::net::TcpStream::connect(socket)?; stream.write_all(b"GET /healthz HTTP/1.0\r\nHost: localhost\r\n\r\n")?; let mut response = String::new(); stream.read_to_string(&mut response)?; diff --git a/ocsp-responder/src/store.rs b/ocsp-responder/src/store.rs index 42ff1e9..d3edb8c 100644 --- a/ocsp-responder/src/store.rs +++ b/ocsp-responder/src/store.rs @@ -46,12 +46,12 @@ impl ObjectStore for StatusStore { .key(key) .send() .await - .map_err(|error| StoreError::S3(error.to_string()))?; + .map_err(|error| StoreError::S3(format!("{error:?}")))?; let data = response .body .collect() .await - .map_err(|error| StoreError::S3(error.to_string()))? + .map_err(|error| StoreError::S3(format!("{error:?}")))? .into_bytes(); Ok(data) }