-
Notifications
You must be signed in to change notification settings - Fork 0
Implement acme.sh-based certificate revocation lifecycle #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
053d217
Implement acme.sh-based certificate revocation lifecycle
streaky a034329
resume pending revocation idempotency records
streaky 895bec8
fix: harden acme.sh certificate revocation per review notes
streaky df7a5b6
revocation webhook and handling missing account config
streaky 5ac7332
fix: support bodyless certificate revocations
streaky 80e3c9b
note revoke limits imposed by the current acme.sh revoke implementation
streaky 1ca6c94
accept alreadyRevoked as idempotent success
streaky d77814e
use correct key slot when revoking, dispatch revoke fail webhooks
streaky 98b3f4f
a little proactive fix
streaky 2f38ab8
preserve key_algorithm for DNS-01 issuance
streaky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """Durable records for domain-based ACME certificate revocations.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import datetime as _dt | ||
| import enum | ||
| import uuid as _uuid | ||
|
|
||
| from sqlalchemy import DateTime, Enum, ForeignKey, Integer, String, UniqueConstraint, text | ||
| from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
|
|
||
| from acme_api.models.base import Base | ||
|
|
||
|
|
||
| class CertificateRevocationStatus(enum.StrEnum): | ||
| """Terminal and in-flight states for an acme.sh revocation command.""" | ||
|
|
||
| PENDING = "pending" | ||
| SUCCEEDED = "succeeded" | ||
| FAILED = "failed" | ||
|
|
||
|
|
||
| class CertificateRevocation(Base): | ||
| """One idempotent, domain-based revocation request for a certificate.""" | ||
|
|
||
| __tablename__ = "certificate_revocations" | ||
| __table_args__ = ( | ||
| UniqueConstraint( | ||
| "certificate_id", | ||
| "idempotency_key", | ||
| name="uq_certificate_revocations_certificate_idempotency_key", | ||
| ), | ||
| ) | ||
|
|
||
| id: Mapped[_uuid.UUID] = mapped_column(primary_key=True, default=_uuid.uuid4) | ||
| certificate_id: Mapped[_uuid.UUID] = mapped_column(ForeignKey("certificates.id"), index=True, nullable=False) | ||
| domain: Mapped[str] = mapped_column(String(253), nullable=False) | ||
| reason: Mapped[int | None] = mapped_column(Integer, nullable=True) | ||
| idempotency_key: Mapped[str] = mapped_column(String(255), nullable=False) | ||
| actor: Mapped[str | None] = mapped_column(String(255), nullable=True) | ||
| status: Mapped[CertificateRevocationStatus] = mapped_column( | ||
| Enum(CertificateRevocationStatus), | ||
| default=CertificateRevocationStatus.PENDING, | ||
| nullable=False, | ||
| ) | ||
| error_category: Mapped[str | None] = mapped_column(String(32), nullable=True) | ||
| error_details: Mapped[str | None] = mapped_column(String(2048), nullable=True) | ||
| created_at: Mapped[_dt.datetime] = mapped_column( | ||
| DateTime(timezone=True), server_default=text("CURRENT_TIMESTAMP"), nullable=False | ||
| ) | ||
| attempt_started_at: Mapped[_dt.datetime | None] = mapped_column(DateTime(timezone=True), nullable=True) | ||
| completed_at: Mapped[_dt.datetime | None] = mapped_column(DateTime(timezone=True), nullable=True) | ||
|
|
||
| certificate = relationship( | ||
| "acme_api.models.certificate.Certificate", | ||
| back_populates="revocations", | ||
| lazy="selectin", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.