A high-level asynchronous interface for managing a vaultâs certificates.
vault_url (str) â URL of the vault the client will access. This is also called the vaultâs âDNS Nameâ. You should validate that this URL references a valid Key Vault resource. See https://aka.ms/azsdk/blog/vault-uri for details.
credential (AsyncTokenCredential) â An object which can provide an access token for the vault, such as a credential from azure.identity.aio
api_version (ApiVersion or str) â Version of the service API to use. Defaults to the most recent.
verify_challenge_resource (bool) â Whether to verify the authentication challenge resource matches the Key Vault domain. Defaults to True.
Example
Creates a new instance of the Certificate clientïfrom azure.identity.aio import DefaultAzureCredential from azure.keyvault.certificates.aio import CertificateClient # Create a KeyVaultCertificate using default Azure credentials credential = DefaultAzureCredential() certificate_client = CertificateClient(vault_url=vault_url, credential=credential) # the client and credential should be closed when no longer needed # (both are also async context managers) await certificate_client.close() await credential.close()
Back up a certificate in a protected form useable only by Azure Key Vault.
Requires certificates/backup permission. This is intended to allow copying a certificate from one vault to another. Both vaults must be owned by the same Azure subscription. Also, backup / restore cannot be performed across geopolitical boundaries. For example, a backup from a vault in a USA region cannot be restored to a vault in an EU region.
certificate_name (str) â The name of the certificate.
The backup blob containing the backed up certificate.
ResourceNotFoundError or HttpResponseError â the former if the certificate doesnât exist; the latter for other errors
Example
Get a certificate backupï# backup certificate certificate_backup = await certificate_client.backup_certificate(cert_name) # returns the raw bytes of the backed up certificate print(certificate_backup)
Cancels an in-progress certificate operation. Requires the certificates/update permission.
certificate_name (str) â The name of the certificate.
The cancelled certificate operation
Close sockets opened by the client.
Calling this method is unnecessary when using the client as a context manager.
Creates a new certificate.
If this is the first version, the certificate resource is created. This operation requires the certificates/create permission. The poller requires the certificates/get permission, otherwise raises an HttpResponseError
.
certificate_name (str) â The name of the certificate.
policy (CertificatePolicy) â The management policy for the certificate. Either subject or one of the subject alternative name properties are required.
A coroutine for the creation of the certificate. Awaiting the coroutine returns the created KeyVaultCertificate if creation is successful, or the CertificateOperation if not.
ValueError or HttpResponseError â the former if the certificate policy is invalid; the latter for other errors
Example
from azure.keyvault.certificates import CertificatePolicy, CertificateContentType, WellKnownIssuerNames # specify the certificate policy cert_policy = CertificatePolicy( issuer_name=WellKnownIssuerNames.self, subject="CN=*.microsoft.com", san_dns_names=["sdk.azure-int.net"], exportable=True, key_type="RSA", key_size=2048, reuse_key=False, content_type=CertificateContentType.pkcs12, validity_in_months=24, ) certificate = await certificate_client.create_certificate(certificate_name=cert_name, policy=cert_policy) print(certificate.id) print(certificate.name) print(certificate.policy.issuer_name)
Sets the specified certificate issuer. Requires certificates/setissuers permission.
enabled (bool) â Whether the issuer is enabled for use.
account_id (str) â The user name/account name/account id.
password (str) â The password/secret/account key.
organization_id (str) â Id of the organization
admin_contacts (list[AdministratorContact]) â Contact details of the organization administrators of the certificate issuer.
The created CertificateIssuer
Example
from azure.keyvault.certificates import AdministratorContact # First we specify the AdministratorContact for a issuer. admin_contacts = [ AdministratorContact(first_name="John", last_name="Doe", email="admin@microsoft.com", phone="4255555555") ] issuer = await certificate_client.create_issuer( issuer_name="issuer1", provider="Test", account_id="keyvaultuser", admin_contacts=admin_contacts, enabled=True, ) print(issuer.name) print(issuer.provider) print(issuer.account_id) for contact in issuer.admin_contacts: print(contact.first_name) print(contact.last_name) print(contact.email) print(contact.phone)
Delete all versions of a certificate. Requires certificates/delete permission.
If the vault has soft-delete enabled, deletion may take several seconds to complete.
certificate_name (str) â The name of the certificate.
The deleted certificate
ResourceNotFoundError or HttpResponseError â the former if the certificate doesnât exist; the latter for other errors
Example
# delete a certificate deleted_certificate = await certificate_client.delete_certificate(cert_name) print(deleted_certificate.name) # if the vault has soft-delete enabled, the certificate's # scheduled purge date, deleted_on, and recovery id are available print(deleted_certificate.deleted_on) print(deleted_certificate.scheduled_purge_date) print(deleted_certificate.recovery_id)
Deletes and stops the creation operation for a specific certificate.
Requires the certificates/update permission.
certificate_name (str) â The name of the certificate.
The deleted CertificateOperation
ResourceNotFoundError or HttpResponseError â the former if the operation doesnât exist; the latter for other errors
Deletes the certificate contacts for the key vault. Requires the certificates/managecontacts permission.
The deleted contacts for the key vault.
Example
deleted_contacts = await certificate_client.delete_contacts() for deleted_contact in deleted_contacts: print(deleted_contact.name) print(deleted_contact.email) print(deleted_contact.phone)
Deletes the specified certificate issuer.
Requires certificates/manageissuers/deleteissuers permission.
issuer_name (str) â The name of the issuer.
CertificateIssuer
Example
deleted_issuer = await certificate_client.delete_issuer("issuer1") print(deleted_issuer.name) print(deleted_issuer.provider) print(deleted_issuer.account_id) for contact in deleted_issuer.admin_contacts: print(contact.first_name) print(contact.last_name) print(contact.email) print(contact.phone)
Gets a certificate with its management policy attached. Requires certificates/get permission.
Does not accept the version of the certificate as a parameter. To get a specific version of the certificate, call get_certificate_version()
.
certificate_name (str) â The name of the certificate in the given vault.
An instance of KeyVaultCertificate
ResourceNotFoundError or HttpResponseError â the former if the certificate doesnât exist; the latter for other errors
Example
# get the latest version of a certificate certificate = await certificate_client.get_certificate(cert_name) print(certificate.id) print(certificate.name) print(certificate.policy.issuer_name)
Gets the creation operation of a certificate. Requires the certificates/get permission.
certificate_name (str) â The name of the certificate.
The created CertificateOperation
ResourceNotFoundError or HttpResponseError â the former if the certificate doesnât exist; the latter for other errors
Gets the policy for a certificate. Requires certificates/get permission.
Returns the specified certificate policy resources in the key vault.
certificate_name (str) â The name of the certificate in a given key vault.
The certificate policy
Gets a specific version of a certificate without returning its management policy.
Requires certificates/get permission. To get the latest version of the certificate, or to get the certificateâs policy as well, call get_certificate()
.
An instance of KeyVaultCertificate
ResourceNotFoundError or HttpResponseError â the former if the certificate doesnât exist; the latter for other errors
Example
Get a certificate with a specific versionïcertificate = await certificate_client.get_certificate_version(cert_name, version) print(certificate.id) print(certificate.properties.version)
Gets the certificate contacts for the key vault. Requires the certificates/managecontacts permission.
The certificate contacts for the key vault.
Example
contacts = await certificate_client.get_contacts() # Loop through the certificate contacts for this key vault. for contact in contacts: print(contact.name) print(contact.email) print(contact.phone)
Get a deleted certificate. Possible only in a vault with soft-delete enabled.
Requires certificates/get permission. Retrieves the deleted certificate information plus its attributes, such as retention interval, scheduled permanent deletion, and the current deletion recovery level.
certificate_name (str) â The name of the certificate.
The deleted certificate
ResourceNotFoundError or HttpResponseError â the former if the certificate doesnât exist; the latter for other errors
Example
Get a deleted certificateï# get a deleted certificate (requires soft-delete enabled for the vault) deleted_certificate = await certificate_client.get_deleted_certificate(cert_name) print(deleted_certificate.name)
Gets the specified certificate issuer. Requires certificates/manageissuers/getissuers permission.
issuer_name (str) â The name of the issuer.
The specified certificate issuer.
ResourceNotFoundError or HttpResponseError â the former if the issuer doesnât exist; the latter for other errors
Example
issuer = await certificate_client.get_issuer("issuer1") print(issuer.name) print(issuer.provider) print(issuer.account_id) for contact in issuer.admin_contacts: print(contact.first_name) print(contact.last_name) print(contact.email) print(contact.phone)
Import a certificate created externally. Requires certificates/import permission.
Imports an existing valid certificate, containing a private key, into Azure Key Vault. The certificate to be imported can be in either PFX or PEM format. If the certificate is in PEM format the PEM file must contain the key as well as x509 certificates, and you must provide a policy
with content_type
of pem
.
enabled (bool) â Whether the certificate is enabled for use.
tags (dict[str, str]) â Application specific metadata in the form of key-value pairs.
password (str) â If the private key in the passed in certificate is encrypted, it is the password used for encryption.
policy (CertificatePolicy) â The management policy for the certificate. Required if importing a PEM-format certificate, with content_type
set to pem
.
preserve_order (bool) â Whether to preserve the order of the certificate chain.
The imported KeyVaultCertificate
Lists the currently-recoverable deleted certificates. Possible only if vault is soft-delete enabled.
Requires certificates/get/list permission. Retrieves the certificates in the current vault which are in a deleted state and ready for recovery or purging. This operation includes deletion-specific information.
include_pending (bool or None) â Specifies whether to include certificates which are not completely deleted. Only available for API versions v7.0 and up. If not provided, Key Vault treats this as False.
An iterator-like instance of DeletedCertificate
Example
List all the deleted certificatesï# get an iterator of deleted certificates (requires soft-delete enabled for the vault) deleted_certificates = certificate_client.list_deleted_certificates() async for certificate in deleted_certificates: print(certificate.id) print(certificate.name) print(certificate.scheduled_purge_date) print(certificate.recovery_id) print(certificate.deleted_on)
List the identifiers and properties of a certificateâs versions.
Requires certificates/list permission.
certificate_name (str) â The name of the certificate.
An iterator-like instance of CertificateProperties
Example
List all versions of a certificateï# get an iterator of all versions of a certificate certificate_versions = certificate_client.list_properties_of_certificate_versions(certificate_name) async for certificate in certificate_versions: print(certificate.id) print(certificate.updated_on) print(certificate.version)
List identifiers and properties of all certificates in the vault.
Requires certificates/list permission.
include_pending (bool or None) â Specifies whether to include certificates which are not completely provisioned. Only available for API versions v7.0 and up. If not provided, Key Vault treats this as False.
An iterator-like instance of CertificateProperties
Example
# list certificates certificates = certificate_client.list_properties_of_certificates() async for certificate in certificates: print(certificate.id) print(certificate.created_on) print(certificate.name) print(certificate.updated_on) print(certificate.enabled)
Lists properties of the certificate issuers for the key vault.
Requires the certificates/manageissuers/getissuers permission.
An iterator-like instance of Issuers
Example
List issuers of a vaultïissuers = certificate_client.list_properties_of_issuers() async for issuer in issuers: print(issuer.name) print(issuer.provider)
Merges a certificate or a certificate chain with a key pair existing on the server.
Requires the certificates/create permission. Performs the merging of a certificate or certificate chain with a key pair currently available in the service. Make sure when creating the certificate to merge using create_certificate()
that you set its issuer to âUnknownâ. This way Key Vault knows that the certificate will not be signed by an issuer known to it.
The merged certificate operation
Permanently deletes a deleted certificate. Possible only in vaults with soft-delete enabled.
Requires certificates/purge permission. Performs an irreversible deletion of the specified certificate, without possibility for recovery. The operation is not available if the recovery_level
does not specify âPurgeableâ. This method is only necessary for purging a certificate before its scheduled_purge_date
.
certificate_name (str) â The name of the certificate
None
None
Recover a deleted certificate to its latest version. Possible only in a vault with soft-delete enabled.
Requires certificates/recover permission. If the vault does not have soft-delete enabled, delete_certificate()
is permanent, and this method will raise an error. Attempting to recover a non-deleted certificate will also raise an error.
certificate_name (str) â The name of the deleted certificate
The recovered certificate
Example
Recover a deleted certificateï# recover deleted certificate to its latest version (requires soft-delete enabled for the vault) recovered_certificate = await certificate_client.recover_deleted_certificate(cert_name) print(recovered_certificate.id) print(recovered_certificate.name)
Restore a certificate backup to the vault. Requires certificates/restore permission.
This restores all versions of the certificate, with its name, attributes, and access control policies. If the certificateâs name is already in use, restoring it will fail. Also, the target vault must be owned by the same Microsoft Azure subscription as the source vault.
backup (bytes) â The backup blob associated with a certificate bundle.
The restored KeyVaultCertificate
Example
Restore a certificate backupï# restores a certificate backup restored_certificate = await certificate_client.restore_certificate_backup(certificate_backup) print(restored_certificate.id) print(restored_certificate.name) print(restored_certificate.properties.version)
Runs a network request using the clientâs existing pipeline.
The request URL can be relative to the vault URL. The service API version used for the request is the same as the clientâs unless otherwise specified. This method does not raise if the response is an error; to raise an exception, call raise_for_status() on the returned response object. For more information about how to send custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request.
request (HttpRequest) â The network request you want to make.
stream (bool) â Whether the response payload will be streamed. Defaults to False.
The response of your network call. Does not do error handling on your response.
Sets the certificate contacts for the key vault. Requires certificates/managecontacts permission.
contacts (list[CertificateContact]) â The contact list for the vault certificates.
The created list of contacts
Example
from azure.keyvault.certificates import CertificateContact # Create a list of the contacts that you want to set for this key vault. contact_list = [ CertificateContact(email="admin@contoso.com", name="John Doe", phone="1111111111"), CertificateContact(email="admin2@contoso.com", name="John Doe2", phone="2222222222"), ] contacts = await certificate_client.set_contacts(contact_list) for contact in contacts: print(contact.name) print(contact.email) print(contact.phone)
Updates the policy for a certificate. Requires certificates/update permission.
Set specified members in the certificate policy. Leaves others as null.
certificate_name (str) â The name of the certificate in the given vault.
policy (CertificatePolicy) â The policy for the certificate.
The certificate policy
Change a certificateâs properties. Requires certificates/update permission.
The updated KeyVaultCertificate
Example
Update a certificateâs attributesï# update attributes of an existing certificate tags = {"foo": "updated tag"} updated_certificate = await certificate_client.update_certificate_properties( certificate_name=certificate.name, tags=tags ) print(updated_certificate.properties.version) print(updated_certificate.properties.updated_on) print(updated_certificate.properties.tags)
Updates the specified certificate issuer. Requires certificates/setissuers permission.
issuer_name (str) â The name of the issuer.
enabled (bool) â Whether the issuer is enabled for use.
provider (str) â The issuer provider
account_id (str) â The user name/account name/account id.
password (str) â The password/secret/account key.
organization_id (str) â Id of the organization
admin_contacts (list[AdministratorContact]) â Contact details of the organization administrators of the certificate issuer
The updated issuer
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4