tigrbl_acme_ca 0.1.1.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tigrbl_acme_ca-0.1.1.dev2/LICENSE +176 -0
- tigrbl_acme_ca-0.1.1.dev2/PKG-INFO +68 -0
- tigrbl_acme_ca-0.1.1.dev2/README.md +50 -0
- tigrbl_acme_ca-0.1.1.dev2/pyproject.toml +38 -0
- tigrbl_acme_ca-0.1.1.dev2/setup.cfg +4 -0
- tigrbl_acme_ca-0.1.1.dev2/tests/test_smoke.py +8 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/adapters/jws_to_ctx.py +95 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/adapters/results_to_http.py +37 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/app/api_spec.py +17 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/app/app_spec.py +17 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/app/table_spec.py +25 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/domain/errors.py +5 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/domain/models.py +24 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/engines/acme_signing/__init__.py +4 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/engines/acme_signing/engine.py +54 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/engines/acme_signing/session.py +17 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/key_mgmt/__init__.py +10 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/key_mgmt/ca_key_loader.py +39 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/key_mgmt/providers.py +56 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/libs/__init__.py +4 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/libs/sw_cert_service.py +129 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/libs/sw_kms.py +49 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/directory.py +21 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/finalize.py +99 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/get_authz.py +27 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/get_cert.py +27 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/key_change.py +43 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/new_account.py +60 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/new_nonce.py +44 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/new_order.py +100 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/post_challenge.py +91 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/acme/revoke.py +62 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/guards/jws_envelope_guard.py +33 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/ops/guards/ratelimit.py +11 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/schema/csr_finalize_extra.py +13 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/schema/directory_extra.py +20 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/audit/auditor.py +107 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/audit/redact.py +15 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/ca/chain_builder.py +21 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/ca/csr_service.py +8 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/ca/issuance_service.py +136 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/ca/policy.py +51 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/compliance/control_enforcers.py +24 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/compliance/evidence_hooks.py +58 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/integration/cloud_dns/aws_route53.py +21 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/integration/cloud_dns/azure_dns.py +29 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/integration/cloud_dns/gcp_dns.py +21 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/integration/webhooks/ct_log_publisher.py +43 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/ra/account_service.py +98 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/ra/nonce_service.py +43 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/ra/order_service.py +118 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/revocation/crl_publisher.py +17 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/revocation/ocsp_responder.py +151 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/revocation/revoke_service.py +65 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/va/challenge_service.py +91 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/va/dns01_validator.py +22 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/services/va/http01_validator.py +13 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/__init__.py +13 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/accounts.py +53 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/audit_events.py +72 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/authorizations.py +61 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/certificates.py +73 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/challenges.py +62 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/external_account_bindings.py +48 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/nonces.py +39 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/orders.py +77 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/revocations.py +50 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tables/tos_agreements.py +50 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/telemetry/metrics.py +91 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/telemetry/tracing.py +64 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tigrbl_acme_ca.egg-info/PKG-INFO +68 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tigrbl_acme_ca.egg-info/SOURCES.txt +78 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tigrbl_acme_ca.egg-info/dependency_links.txt +1 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tigrbl_acme_ca.egg-info/requires.txt +1 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/tigrbl_acme_ca.egg-info/top_level.txt +12 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/workers/__init__.py +1 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/workers/queue.py +40 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/workers/tasks_issuance.py +127 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/workers/tasks_revocation.py +51 -0
- tigrbl_acme_ca-0.1.1.dev2/tigrbl_acme_ca/workers/tasks_validation.py +121 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tigrbl_acme_ca
|
|
3
|
+
Version: 0.1.1.dev2
|
|
4
|
+
Summary: ACME v2 CA tables for Tigrbl.
|
|
5
|
+
Author-email: Jacob Stewart <jacob@swarmauri.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: tigrbl_acme_ca,tigrbl,experimental
|
|
8
|
+
Classifier: Development Status :: 1 - Planning
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Python: <3.13,>=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: tigrbl>=0.3.0.dev4
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# tigrbl_acme_ca
|
|
20
|
+
|
|
21
|
+
A Tigrbl-native ACME v2 Certificate Authority implementation.
|
|
22
|
+
|
|
23
|
+
## Highlights
|
|
24
|
+
|
|
25
|
+
- **Tables-first** design: all I/O derives from `tables/` column specs.
|
|
26
|
+
- **Canon verbs**: write flows use model-bound ops that alias to built-in Tigrbl verbs.
|
|
27
|
+
- **Ops/Hooks** only use the request `ctx` and SQLAlchemy session—**no kernel atoms**.
|
|
28
|
+
- **HSM/KMS-ready**: pluggable key providers (file, KMS, PKCS#11 stubs) and a signing engine.
|
|
29
|
+
- **OCSP/CRL/CT**: hooks and workers to publish CRLs, answer OCSP, and submit to CT logs.
|
|
30
|
+
- **Compliance**: audit/evidence hooks, redaction, and control enforcers.
|
|
31
|
+
- **Telemetry**: Prometheus metrics and OpenTelemetry tracing (optional).
|
|
32
|
+
|
|
33
|
+
## Layout
|
|
34
|
+
|
|
35
|
+
- `tables/` — database schema (Account, Order, Authorization, Challenge, Certificate, Revocation, Nonce, etc.).
|
|
36
|
+
- `app/` — AppSpec, TableSpec, ApiSpec.
|
|
37
|
+
- `ops/` — ACME verbs and guards.
|
|
38
|
+
- `services/` — RA/VA/CA/Revocation/Audit/Compliance/Integrations.
|
|
39
|
+
- `engines/` — signing engine and session.
|
|
40
|
+
- `key_mgmt/` — key provider interfaces + loader.
|
|
41
|
+
- `libs/` — cert issuance logic and KMS adapter.
|
|
42
|
+
- `workers/` — background tasks (validation, issuance, revocation).
|
|
43
|
+
- `telemetry/` — tracing + metrics helpers.
|
|
44
|
+
- `adapters/` — first-party adapters (JWS parser, HTTP negotiation).
|
|
45
|
+
|
|
46
|
+
## Dev Quickstart
|
|
47
|
+
|
|
48
|
+
1. Install dependencies (pseudo):
|
|
49
|
+
```bash
|
|
50
|
+
pip install -e . # plus your runtime/gateway deps
|
|
51
|
+
```
|
|
52
|
+
2. Configure a dev CA key:
|
|
53
|
+
```toml
|
|
54
|
+
[acme.ca]
|
|
55
|
+
key_source = "file"
|
|
56
|
+
key_path = "ca.key.pem"
|
|
57
|
+
```
|
|
58
|
+
3. Wire a `signing_engine` into your gateway context:
|
|
59
|
+
```python
|
|
60
|
+
from tigrbl_acme_ca.engines.acme_signing import AcmeSigningEngine
|
|
61
|
+
engine = AcmeSigningEngine.from_config(app_config)
|
|
62
|
+
ctx["signing_engine"] = engine
|
|
63
|
+
```
|
|
64
|
+
4. Hit ACME endpoints: `/.well-known/acme-directory`, `/acme/new-nonce`, `/acme/new-account`, `/acme/new-order`.
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
Apache License 2.0 — see `LICENSE`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# tigrbl_acme_ca
|
|
2
|
+
|
|
3
|
+
A Tigrbl-native ACME v2 Certificate Authority implementation.
|
|
4
|
+
|
|
5
|
+
## Highlights
|
|
6
|
+
|
|
7
|
+
- **Tables-first** design: all I/O derives from `tables/` column specs.
|
|
8
|
+
- **Canon verbs**: write flows use model-bound ops that alias to built-in Tigrbl verbs.
|
|
9
|
+
- **Ops/Hooks** only use the request `ctx` and SQLAlchemy session—**no kernel atoms**.
|
|
10
|
+
- **HSM/KMS-ready**: pluggable key providers (file, KMS, PKCS#11 stubs) and a signing engine.
|
|
11
|
+
- **OCSP/CRL/CT**: hooks and workers to publish CRLs, answer OCSP, and submit to CT logs.
|
|
12
|
+
- **Compliance**: audit/evidence hooks, redaction, and control enforcers.
|
|
13
|
+
- **Telemetry**: Prometheus metrics and OpenTelemetry tracing (optional).
|
|
14
|
+
|
|
15
|
+
## Layout
|
|
16
|
+
|
|
17
|
+
- `tables/` — database schema (Account, Order, Authorization, Challenge, Certificate, Revocation, Nonce, etc.).
|
|
18
|
+
- `app/` — AppSpec, TableSpec, ApiSpec.
|
|
19
|
+
- `ops/` — ACME verbs and guards.
|
|
20
|
+
- `services/` — RA/VA/CA/Revocation/Audit/Compliance/Integrations.
|
|
21
|
+
- `engines/` — signing engine and session.
|
|
22
|
+
- `key_mgmt/` — key provider interfaces + loader.
|
|
23
|
+
- `libs/` — cert issuance logic and KMS adapter.
|
|
24
|
+
- `workers/` — background tasks (validation, issuance, revocation).
|
|
25
|
+
- `telemetry/` — tracing + metrics helpers.
|
|
26
|
+
- `adapters/` — first-party adapters (JWS parser, HTTP negotiation).
|
|
27
|
+
|
|
28
|
+
## Dev Quickstart
|
|
29
|
+
|
|
30
|
+
1. Install dependencies (pseudo):
|
|
31
|
+
```bash
|
|
32
|
+
pip install -e . # plus your runtime/gateway deps
|
|
33
|
+
```
|
|
34
|
+
2. Configure a dev CA key:
|
|
35
|
+
```toml
|
|
36
|
+
[acme.ca]
|
|
37
|
+
key_source = "file"
|
|
38
|
+
key_path = "ca.key.pem"
|
|
39
|
+
```
|
|
40
|
+
3. Wire a `signing_engine` into your gateway context:
|
|
41
|
+
```python
|
|
42
|
+
from tigrbl_acme_ca.engines.acme_signing import AcmeSigningEngine
|
|
43
|
+
engine = AcmeSigningEngine.from_config(app_config)
|
|
44
|
+
ctx["signing_engine"] = engine
|
|
45
|
+
```
|
|
46
|
+
4. Hit ACME endpoints: `/.well-known/acme-directory`, `/acme/new-nonce`, `/acme/new-account`, `/acme/new-order`.
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
Apache License 2.0 — see `LICENSE`.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tigrbl_acme_ca"
|
|
3
|
+
version = "0.1.1.dev2"
|
|
4
|
+
description = "ACME v2 CA tables for Tigrbl."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.13"
|
|
7
|
+
license = { text = "Apache-2.0" }
|
|
8
|
+
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 1 - Planning",
|
|
11
|
+
"License :: OSI Approved :: Apache Software License",
|
|
12
|
+
"Programming Language :: Python :: 3.10",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
]
|
|
16
|
+
keywords = ["tigrbl_acme_ca", "tigrbl", "experimental"]
|
|
17
|
+
dependencies = ["tigrbl>=0.3.0.dev4"]
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["setuptools>=68", "wheel"]
|
|
21
|
+
build-backend = "setuptools.build_meta"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["tigrbl_acme_ca"]
|
|
25
|
+
|
|
26
|
+
[dependency-groups]
|
|
27
|
+
dev = [
|
|
28
|
+
"pytest>=8.0",
|
|
29
|
+
"pytest-asyncio>=0.24.0",
|
|
30
|
+
"pytest-xdist>=3.6.1",
|
|
31
|
+
"pytest-json-report>=1.5.0",
|
|
32
|
+
"python-dotenv",
|
|
33
|
+
"requests>=2.32.3",
|
|
34
|
+
"flake8>=7.0",
|
|
35
|
+
"pytest-timeout>=2.3.1",
|
|
36
|
+
"ruff>=0.9.9",
|
|
37
|
+
"pytest-benchmark>=4.0.0",
|
|
38
|
+
]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_package_assets_present() -> None:
|
|
5
|
+
package_dir = Path(__file__).resolve().parents[1]
|
|
6
|
+
assert (package_dir / "README.md").is_file()
|
|
7
|
+
assert (package_dir / "LICENSE").is_file()
|
|
8
|
+
assert (package_dir / "pyproject.toml").is_file()
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import json
|
|
5
|
+
import hashlib
|
|
6
|
+
from typing import Any, Dict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _b64url_to_bytes(data: str) -> bytes:
|
|
10
|
+
pad = "=" * (-len(data) % 4)
|
|
11
|
+
return base64.urlsafe_b64decode(data + pad)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _b64url(data: bytes) -> str:
|
|
15
|
+
return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _canonical_json(obj: Dict[str, Any]) -> bytes:
|
|
19
|
+
# RFC 7638: lexicographic, separators without spaces, ensure_ascii True
|
|
20
|
+
return json.dumps(
|
|
21
|
+
obj, sort_keys=True, separators=(",", ":"), ensure_ascii=True
|
|
22
|
+
).encode("ascii")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def jwk_thumbprint(jwk: Dict[str, Any]) -> str:
|
|
26
|
+
"""Compute RFC 7638 JWK thumbprint (SHA-256 of canonical JSON).
|
|
27
|
+
Supports RSA (kty/e/n) and EC (kty/crv/x/y).
|
|
28
|
+
"""
|
|
29
|
+
kty = jwk.get("kty")
|
|
30
|
+
if kty == "RSA":
|
|
31
|
+
material = {"e": jwk["e"], "kty": "RSA", "n": jwk["n"]}
|
|
32
|
+
elif kty == "EC":
|
|
33
|
+
material = {"crv": jwk["crv"], "kty": "EC", "x": jwk["x"], "y": jwk["y"]}
|
|
34
|
+
else:
|
|
35
|
+
raise ValueError("unsupported_jwk_kty")
|
|
36
|
+
digest = hashlib.sha256(_canonical_json(material)).digest()
|
|
37
|
+
return _b64url(digest)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def parse_acme_jws_from_body(body: bytes) -> Dict[str, Any]:
|
|
41
|
+
"""Parse an ACME JWS object (JSON with base64url fields) from HTTP body.
|
|
42
|
+
Returns a dict with keys: protected (str), payload (str), signature (str), header (dict).
|
|
43
|
+
This function DOES NOT verify signatures; guards/engines should perform that step if needed.
|
|
44
|
+
"""
|
|
45
|
+
try:
|
|
46
|
+
obj = json.loads(body.decode("utf-8"))
|
|
47
|
+
protected = obj.get("protected")
|
|
48
|
+
payload = obj.get("payload")
|
|
49
|
+
signature = obj.get("signature")
|
|
50
|
+
if not (
|
|
51
|
+
isinstance(protected, str)
|
|
52
|
+
and isinstance(payload, str)
|
|
53
|
+
and isinstance(signature, str)
|
|
54
|
+
):
|
|
55
|
+
raise ValueError("malformed_jws")
|
|
56
|
+
header_raw = _b64url_to_bytes(protected)
|
|
57
|
+
header = json.loads(header_raw.decode("utf-8"))
|
|
58
|
+
obj["header"] = header
|
|
59
|
+
return obj
|
|
60
|
+
except Exception as e:
|
|
61
|
+
raise ValueError(f"malformed_jws:{e}")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def populate_ctx_from_jws(ctx: Dict[str, Any], jws: Dict[str, Any]) -> None:
|
|
65
|
+
"""Populate the Tigrbl request ctx with ACME JWS fields.
|
|
66
|
+
- ctx['jws'] original object
|
|
67
|
+
- ctx['jws_header'] parsed protected header
|
|
68
|
+
- ctx['jws_payload_b64'] base64url payload (do not decode here)
|
|
69
|
+
- ctx['request_nonce'] from protected header 'nonce'
|
|
70
|
+
- ctx['account_kid'] from protected header 'kid' (if present)
|
|
71
|
+
- ctx['account_jwk'] from protected header 'jwk' (if present)
|
|
72
|
+
- ctx['request_url'] from protected header 'url' (if present)
|
|
73
|
+
- ctx['actor_account_thumbprint'] optional computed from jwk
|
|
74
|
+
"""
|
|
75
|
+
header = jws.get("header") or {}
|
|
76
|
+
ctx["jws"] = jws
|
|
77
|
+
ctx["jws_header"] = header
|
|
78
|
+
ctx["jws_payload_b64"] = jws.get("payload")
|
|
79
|
+
nonce = header.get("nonce")
|
|
80
|
+
if nonce:
|
|
81
|
+
ctx["request_nonce"] = nonce
|
|
82
|
+
kid = header.get("kid")
|
|
83
|
+
jwk = header.get("jwk")
|
|
84
|
+
if kid:
|
|
85
|
+
ctx["account_kid"] = kid
|
|
86
|
+
if jwk:
|
|
87
|
+
ctx["account_jwk"] = jwk
|
|
88
|
+
try:
|
|
89
|
+
ctx["actor_account_thumbprint"] = jwk_thumbprint(jwk)
|
|
90
|
+
except Exception:
|
|
91
|
+
# ignore if unsupported/invalid
|
|
92
|
+
pass
|
|
93
|
+
url = header.get("url")
|
|
94
|
+
if url:
|
|
95
|
+
ctx["request_url"] = url
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Tuple, List
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _get_accept(ctx) -> str:
|
|
7
|
+
hdrs = ctx.get("request_headers") or {}
|
|
8
|
+
return hdrs.get("accept") or hdrs.get("Accept") or "*/*"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def attach_replay_nonce(ctx, value: str) -> None:
|
|
12
|
+
try:
|
|
13
|
+
headers = ctx.response_headers()
|
|
14
|
+
headers["Replay-Nonce"] = value
|
|
15
|
+
except Exception:
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def negotiate_cert_response(
|
|
20
|
+
ctx, pem: str, chain: List[str] | None = None
|
|
21
|
+
) -> Tuple[int, Dict[str, str], bytes]:
|
|
22
|
+
"""Negotiate certificate download format based on Accept header.
|
|
23
|
+
application/pem-certificate-chain: full chain as concatenated PEMs
|
|
24
|
+
application/pem-certificate: leaf only
|
|
25
|
+
*/*: default to leaf only
|
|
26
|
+
Returns: (status_code, headers, body_bytes)
|
|
27
|
+
"""
|
|
28
|
+
accept = _get_accept(ctx).lower()
|
|
29
|
+
headers: Dict[str, str] = {}
|
|
30
|
+
if "application/pem-certificate-chain" in accept and chain:
|
|
31
|
+
body = ("\n".join(chain)).encode("utf-8")
|
|
32
|
+
headers["Content-Type"] = "application/pem-certificate-chain"
|
|
33
|
+
return 200, headers, body
|
|
34
|
+
# default: leaf certificate
|
|
35
|
+
body = pem.encode("utf-8")
|
|
36
|
+
headers["Content-Type"] = "application/pem-certificate"
|
|
37
|
+
return 200, headers, body
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
API_ROUTES = [
|
|
4
|
+
{
|
|
5
|
+
"method": "GET",
|
|
6
|
+
"path": "/.well-known/acme-directory",
|
|
7
|
+
"handler": "schema.directory_extra:build_directory",
|
|
8
|
+
},
|
|
9
|
+
{"method": "HEAD", "path": "/acme/new-nonce", "handler": "tables.Nonce:new_nonce"},
|
|
10
|
+
{"method": "GET", "path": "/acme/new-nonce", "handler": "tables.Nonce:new_nonce"},
|
|
11
|
+
{
|
|
12
|
+
"method": "POST",
|
|
13
|
+
"path": "/acme/new-account",
|
|
14
|
+
"handler": "tables.Account:new_account",
|
|
15
|
+
},
|
|
16
|
+
{"method": "POST", "path": "/acme/new-order", "handler": "tables.Order:new_order"},
|
|
17
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AcmeCaAppSpec:
|
|
5
|
+
name = "tigrbl_acme_ca"
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
|
|
8
|
+
def load_tables(self):
|
|
9
|
+
from tigrbl_acme_ca.app.table_spec import TABLES
|
|
10
|
+
|
|
11
|
+
_ = [t for t in TABLES]
|
|
12
|
+
return TABLES
|
|
13
|
+
|
|
14
|
+
def load_api(self):
|
|
15
|
+
from tigrbl_acme_ca.app.api_spec import API_ROUTES
|
|
16
|
+
|
|
17
|
+
return API_ROUTES
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from tigrbl_acme_ca.tables.accounts import Account
|
|
4
|
+
from tigrbl_acme_ca.tables.orders import Order
|
|
5
|
+
from tigrbl_acme_ca.tables.authorizations import Authorization
|
|
6
|
+
from tigrbl_acme_ca.tables.challenges import Challenge
|
|
7
|
+
from tigrbl_acme_ca.tables.certificates import Certificate
|
|
8
|
+
from tigrbl_acme_ca.tables.revocations import Revocation
|
|
9
|
+
from tigrbl_acme_ca.tables.nonces import Nonce
|
|
10
|
+
from tigrbl_acme_ca.tables.audit_events import AuditEvent
|
|
11
|
+
from tigrbl_acme_ca.tables.external_account_bindings import ExternalAccountBinding
|
|
12
|
+
from tigrbl_acme_ca.tables.tos_agreements import TosAgreement
|
|
13
|
+
|
|
14
|
+
TABLES = [
|
|
15
|
+
Account,
|
|
16
|
+
Order,
|
|
17
|
+
Authorization,
|
|
18
|
+
Challenge,
|
|
19
|
+
Certificate,
|
|
20
|
+
Revocation,
|
|
21
|
+
Nonce,
|
|
22
|
+
AuditEvent,
|
|
23
|
+
ExternalAccountBinding,
|
|
24
|
+
TosAgreement,
|
|
25
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class OrderStatus(str, Enum):
|
|
6
|
+
pending = "pending"
|
|
7
|
+
ready = "ready"
|
|
8
|
+
processing = "processing"
|
|
9
|
+
valid = "valid"
|
|
10
|
+
invalid = "invalid"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AuthorizationStatus(str, Enum):
|
|
14
|
+
pending = "pending"
|
|
15
|
+
valid = "valid"
|
|
16
|
+
invalid = "invalid"
|
|
17
|
+
expired = "expired"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ChallengeStatus(str, Enum):
|
|
21
|
+
pending = "pending"
|
|
22
|
+
processing = "processing"
|
|
23
|
+
valid = "valid"
|
|
24
|
+
invalid = "invalid"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from datetime import datetime, timedelta, timezone
|
|
4
|
+
from typing import Any, Dict, List
|
|
5
|
+
|
|
6
|
+
from tigrbl_acme_ca.libs.sw_cert_service import CertService, IssueResult
|
|
7
|
+
from tigrbl_acme_ca.key_mgmt.ca_key_loader import CaKeyLoader
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class AcmeSigningEngine:
|
|
12
|
+
"""Thin engine that issues end-entity certificates for ACME Orders.
|
|
13
|
+
|
|
14
|
+
It delegates to a CertService (which may use cryptography or a backend)
|
|
15
|
+
and a CaKeyLoader (which provides the issuing CA key material or adapter).
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
cert_service: CertService
|
|
19
|
+
key_loader: CaKeyLoader
|
|
20
|
+
default_validity_days: int = 90
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def from_config(cls, config: dict) -> "AcmeSigningEngine":
|
|
24
|
+
service = CertService.from_config(config or {})
|
|
25
|
+
loader = CaKeyLoader.from_config(config or {})
|
|
26
|
+
return cls(
|
|
27
|
+
cert_service=service,
|
|
28
|
+
key_loader=loader,
|
|
29
|
+
default_validity_days=int((config or {}).get("acme.validity_days", 90)),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
async def issue_certificate(
|
|
33
|
+
self, *, csr_der: bytes, sans: List[str]
|
|
34
|
+
) -> Dict[str, Any]:
|
|
35
|
+
now = datetime.now(timezone.utc)
|
|
36
|
+
not_before = now
|
|
37
|
+
not_after = now + timedelta(days=self.default_validity_days)
|
|
38
|
+
|
|
39
|
+
issuer = (
|
|
40
|
+
await self.key_loader.load_issuer_key()
|
|
41
|
+
) # may be a cryptography key or adapter
|
|
42
|
+
issued: IssueResult = await self.cert_service.issue_certificate(
|
|
43
|
+
csr_der=csr_der,
|
|
44
|
+
sans=sans,
|
|
45
|
+
issuer_key=issuer,
|
|
46
|
+
not_before=not_before,
|
|
47
|
+
not_after=not_after,
|
|
48
|
+
)
|
|
49
|
+
return {
|
|
50
|
+
"pem": issued.pem,
|
|
51
|
+
"serial_hex": issued.serial_hex,
|
|
52
|
+
"not_before": issued.not_before,
|
|
53
|
+
"not_after": issued.not_after,
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Any, Dict, List
|
|
4
|
+
|
|
5
|
+
from tigrbl_acme_ca.engines.acme_signing.engine import AcmeSigningEngine
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class AcmeSigningSession:
|
|
10
|
+
"""Optional per-request session wrapper around the engine."""
|
|
11
|
+
|
|
12
|
+
engine: AcmeSigningEngine
|
|
13
|
+
|
|
14
|
+
async def issue_certificate(
|
|
15
|
+
self, *, csr_der: bytes, sans: List[str]
|
|
16
|
+
) -> Dict[str, Any]:
|
|
17
|
+
return await self.engine.issue_certificate(csr_der=csr_der, sans=sans)
|