Product knowledge · Advanced · Security boundary

Mã hóa đường đi không tự quyết định ai được làm gì.

Chọn protocol, xác thực transport peer và authorize business action là ba quyết định riêng. CoAkka HTTP Runtime sở hữu hai quyết định đầu ở HTTP edge; application luôn sở hữu quyết định cuối.

01 · Three decisions

Ba lớp bảo vệ, ba owner

1

Protocol có chạy trên target này?

Application gửi intent; exact loaded package báo capability/effective backend. API có enum không chứng minh provider tồn tại.

2

Transport peer là ai?

Runtime validate TLS material, thực hiện handshake và fail closed khi identity/trust không hợp lệ.

3

Peer được phép làm gì?

Application dùng verified peer facts cùng token/session/business policy để authorize route và action.

TLS không thay authorization. mTLS có thể chứng minh client mang certificate được trust, nhưng Core không quyết định certificate đó thuộc customer nào hoặc được charge, đọc hồ sơ hay gọi admin route nào.

02 · Security modes

Chọn mode theo trust boundary thật

ModeServer identityClient identityListener material
PlaintextKhôngKhôngTLS fields rỗng; credential generation bằng 0.
TLSClient verify server certificateKhông bắt buộcNonzero generation, credential ID, certificate chain và private key.
mTLSClient verify server certificateServer verify client certificateTLS material cộng trust roots cho client identity.

Nếu TLS terminate ở reverse proxy, proxy sở hữu certificate và rotation đó. Ghi rõ backend hop dùng plaintext, TLS hay mTLS; một handshake thành công ở proxy không chứng minh CoAkka listener reload.

03 · Listener declaration

Mỗi field trả lời một câu hỏi khác nhau

Protocol
HTTP_1_1 là portable baseline. Chỉ chọn HTTP/2 hoặc HTTP/3 khi exact package/target báo capability tương ứng.
Security mode
Plaintext, TLS hoặc mutual TLS. Provider security vẫn phải feature-check trên target đã load.
Credential ID
Tên ổn định của logical identity, ví dụ partner-api; không chứa secret.
Credential generation
Revision của bộ material mà deployment chọn. Nó không phải file watcher, timestamp, distributed lock hay handshake proof.
Certificate chain
Server identity chain mà peer sẽ verify; giữ file path/mount dưới deployment secret policy.
Private key
Key khớp certificate. Không bake vào image, log, monitor detail hoặc response.
Trust roots
Chỉ bắt buộc cho mTLS để verify client certificate; không phải application allow-list.
listener intent
  address + port
  protocol + security mode
  credential ID + generation
  certificate chain + private key
  trust roots (mTLS only)
            ↓ copy / freeze / validate / bind
accepted → effective listener facts
rejected → typed startup failure; never report ready

04 · Capability before configuration

Public API là vocabulary; loaded package mới là evidence

HTTP/1.1

Built-in baseline. Vẫn kiểm tra handshake, response, bounds và resource return trên matching host.

HTTP/2 và HTTP/3

Shared contract nhưng feature-gated theo target. Không suy support từ enum hoặc package presence.

TLS provider

Security API tồn tại không làm provider tự xuất hiện. Unsupported combination phải fail, không downgrade im lặng.

Effective backend

Đọc protocol/backend runtime đã accept. Linux io_uring chỉ là lựa chọn cho eligible HTTP/2/3 config, không phải nhãn HTTP/1.1.

05 · Application boundary

Verified identity là input, không phải quyết định business

Runtime-owned

Protocol/security validation, handshake, peer trust facts, connection lifetime và transport failure.

Application-owned

Map peer/token/session sang principal, tenant, role, route/action policy và user-safe refusal.

Deployment-owned

Secret distribution, file permissions, certificate issue/revoke, firewall, DNS, ingress và rollout budget.

Không được log

Private keys, tokens, cookies, raw certificates hoặc peer-certificate bytes. Log stable identity/failure facts đã redact.

06 · Fail closed by stage

Failure xảy ra trước handler mang nghĩa khác

StageVí dụKết luận an toàn
StartupMalformed PEM, key mismatch, missing material, unsupported protocol/securityListener không ready; sửa declaration/package/deployment.
HandshakeUnknown CA, expired/not-yet-valid cert, name/policy mismatch, missing client certFail closed trước application handler.
AuthorizationVerified peer nhưng không có quyền với route/actionApplication trả refusal an toàn; transport identity vẫn có thể hợp lệ.
ReloadStale generation hoặc incomplete/invalid candidateRefuse candidate; effective credential cũ không đổi.
RolloutNew instance start được nhưng handshake/request verification failKhông đưa vào ingress; old instance tiếp tục phục vụ.

07 · Nạp lại chứng chỉ · SDK 2.3.0

Publication và retirement là hai outcome

Quy trình này áp dụng cho listener đơn. Listener V1 chưa hỗ trợ mTLS hoặc thay chứng chỉ khi đang chạy trong bản này.

1

Chuẩn bị complete candidate

Dùng distinct paths cho chain, matching key và intended trust roots; không mutate file bên dưới live listener.

2

Đọc effective generation

Lấy generation hiện tại từ running listener; không đoán số tiếp theo từ local state.

3

Apply có expected generation

Submit complete set. Stale/invalid candidate bị refuse và effective state cũ được giữ nguyên.

4

Verify bằng connection mới

Thực hiện real handshake và request; với mTLS, kiểm tra cả trusted client accept và untrusted client reject.

5

Quan sát retirement

Chỉ remove old deployment material sau retirement outcome. Existing connection không tự re-authenticate với trust mới.

Đổi file không phải reload. Overwrite PEM, replace symlink, tăng generation hoặc swap handler đều không tự thay identity của live listener.

08 · Replacement service

Đổi address/protocol là rollout, không phải credential reload

prepare new service at a distinct endpoint
  → start and read effective facts
  → real handshake + request (+ negative mTLS case)
  → admit replacement to ingress
  → stop selecting old instance
  → finite close old service
  → remove old resources only after successful convergence

Dùng replacement khi package/listener không hỗ trợ reload hoặc khi đổi address/protocol. Hai service không mặc nhiên bind cùng endpoint; một process slot duy nhất có thể tạo interruption. Zero downtime không được suy từ recipe. Credential bị compromise có thể cần terminate old sessions thay vì drain bình thường.

09 · Verification checklist

Startup thành công chưa phải evidence đủ