pub struct Certificates<'a> { /* private fields */ }Expand description
TLS certificates of zones, from Client::certificates.
Access is the zone’s: its key, a member of the zone, or an Admin. Every name in a zone
certificate must be served by that zone. Certificates Core issues for redirects
(source = Acme) can be read here but not replaced or deleted.
Implementations§
Source§impl<'a> Certificates<'a>
impl<'a> Certificates<'a>
Sourcepub async fn list(
&self,
zone_id: Option<Uuid>,
page: PageRequest,
) -> Result<Page<Certificate>>
pub async fn list( &self, zone_id: Option<Uuid>, page: PageRequest, ) -> Result<Page<Certificate>>
One page of the certificates of zone_id, or of every zone the caller can access
when None (an Admin also sees platform certificates).
GET /api/v1/certificates[?zone_id=...]
§Errors
ErrorCode::Forbidden if the caller has no access to
zone_id.
Sourcepub async fn covering(&self, name: &str) -> Result<Vec<Certificate>>
pub async fn covering(&self, name: &str) -> Result<Vec<Certificate>>
The visible certificates that cover a host name the way Relay picks them (exact name, or a wildcard one label up). Core allows one certificate per name, so this is normally zero or one.
GET /api/v1/certificates?name=...
Sourcepub async fn get(&self, uuid: Uuid) -> Result<Certificate>
pub async fn get(&self, uuid: Uuid) -> Result<Certificate>
One certificate by uuid.
GET /api/v1/certificates/:uuid
§Errors
ErrorCode::NotFound if there is no such certificate.
Sourcepub async fn create(&self, certificate: &NewCertificate) -> Result<Certificate>
pub async fn create(&self, certificate: &NewCertificate) -> Result<Certificate>
Uploads a certificate for names of a zone; every Relay gets it. Zone members and the zone key may do this.
POST /api/v1/certificates
§Errors
ErrorCode::Validationif the PEM cannot be parsed, is expired, the key does not match, the chain is broken, or there are no SAN names.ErrorCode::Conflictif a name is not served by the zone, has a redirect withtls=Auto(switch it toManualfirst), or is already covered by another certificate.
§Examples
use dinio_sdk::models::NewCertificate;
let zone = client.zones().get("example.com").await?;
let cert = client
.certificates()
.create(&NewCertificate {
chain_pem: std::fs::read_to_string("fullchain.pem").unwrap(),
key_pem: std::fs::read_to_string("privkey.pem").unwrap(),
zone_id: zone.uuid,
})
.await?;
println!("{} valid until {}", cert.names.join(", "), cert.valid_to);Sourcepub async fn replace(
&self,
uuid: Uuid,
renewal: &CertificateRenewal,
) -> Result<Certificate>
pub async fn replace( &self, uuid: Uuid, renewal: &CertificateRenewal, ) -> Result<Certificate>
Replaces chain and key under the same id (renewal). The same name rules as
create apply to the new chain.
PUT /api/v1/certificates/:uuid
§Errors
ErrorCode::ManagedCertificatefor a certificate Core issued for a redirect.- As
create.
Sourcepub async fn delete(&self, uuid: Uuid) -> Result<()>
pub async fn delete(&self, uuid: Uuid) -> Result<()>
Deletes a certificate. Relays fall back to the next match or their default.
DELETE /api/v1/certificates/:uuid
§Errors
ErrorCode::NotFoundif there is no such certificate.ErrorCode::ManagedCertificatefor a certificate Core issued for a redirect.