Class CertificateAsyncClient
certifcates
in the
key vault. The client supports creating, retrieving, updating, merging, deleting, purging, backing up,
restoring and listing the certificates
. The client also supports listing
deleted certificates
for a soft-delete enabled key vault.
The client further allows creating, retrieving, updating, deleting and listing the
certificate issuers
. The client also supports creating, listing and deleting
certificate contacts
Getting Started
In order to interact with the Azure Key Vault service, you will need to create an instance of the
CertificateAsyncClient
class, a vault url and a credential object.
The examples shown in this document use a credential object named DefaultAzureCredential for authentication, which is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using a managed identity for authentication in production environments. You can find more information on different ways of authenticating and their corresponding credential types in the Azure Identity documentation".
Sample: Construct Asynchronous Certificate Client
The following code sample demonstrates the creation of a
CertificateAsyncClient
, using the
CertificateClientBuilder
to configure it.
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .vaultUrl("<your-key-vault-url>") .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) .buildAsyncClient();
Create a Certificate
TheCertificateAsyncClient
can be used to create a certificate in the key vault.
Code Sample:
The following code sample demonstrates how to asynchronously create a certificate in the key vault,
using the beginCreateCertificate(String, CertificatePolicy)
API.
CertificatePolicy certPolicy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); certificateAsyncClient.beginCreateCertificate("certificateName", certPolicy) .subscribe(pollResponse -> { System.out.println("---------------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); System.out.println(pollResponse.getValue().getStatus()); System.out.println(pollResponse.getValue().getStatusDetails()); });
Note: For the synchronous sample, refer to CertificateClient
.
Get a Certificate
TheCertificateAsyncClient
can be used to retrieve a certificate from the key vault.
Code Sample:
The following code sample demonstrates how to asynchronously retrieve a certificate from the key vault, using
the getCertificate(String)
API.
certificateAsyncClient.getCertificate("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateResponse -> System.out.printf("Certificate is returned with name %s and secretId %s %n", certificateResponse.getProperties().getName(), certificateResponse.getSecretId()));
Note: For the synchronous sample, refer to CertificateClient
.
Delete a Certificate
TheCertificateAsyncClient
can be used to delete a certificate from the key vault.
Code Sample:
The following code sample demonstrates how to asynchronously delete a certificate from the Azure
KeyVault, using the beginDeleteCertificate(String)
API.
certificateAsyncClient.beginDeleteCertificate("certificateName") .subscribe(pollResponse -> { System.out.println("Delete Status: " + pollResponse.getStatus().toString()); System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); });
Note: For the synchronous sample, refer to CertificateClient
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionMono
<byte[]> backupCertificate
(String certificateName) Requests that a backup of the specified certificate be downloaded to the client.Mono
<com.azure.core.http.rest.Response<byte[]>> backupCertificateWithResponse
(String certificateName) Requests that a backup of the specified certificate be downloaded to the client.com.azure.core.util.polling.PollerFlux
<CertificateOperation, KeyVaultCertificateWithPolicy> beginCreateCertificate
(String certificateName, CertificatePolicy policy) Creates a new certificate.com.azure.core.util.polling.PollerFlux
<CertificateOperation, KeyVaultCertificateWithPolicy> beginCreateCertificate
(String certificateName, CertificatePolicy policy, Boolean isEnabled, Map<String, String> tags) Creates a new certificate.com.azure.core.util.polling.PollerFlux
<DeletedCertificate, Void> beginDeleteCertificate
(String certificateName) Deletes a certificate from a specified key vault.com.azure.core.util.polling.PollerFlux
<KeyVaultCertificateWithPolicy, Void> beginRecoverDeletedCertificate
(String certificateName) Recovers the deleted certificate back to its current version under /certificates and can only be performed on a soft-delete enabled vault.cancelCertificateOperation
(String certificateName) Cancels a certificate creation operation that is already in progress.Mono
<com.azure.core.http.rest.Response<CertificateOperation>> cancelCertificateOperationWithResponse
(String certificateName) Cancels a certificate creation operation that is already in progress.createIssuer
(CertificateIssuer issuer) Creates the specified certificate issuer.Mono
<com.azure.core.http.rest.Response<CertificateIssuer>> Creates the specified certificate issuer.deleteCertificateOperation
(String certificateName) Deletes the creation operation for the specified certificate that is in the process of being created.Mono
<com.azure.core.http.rest.Response<CertificateOperation>> deleteCertificateOperationWithResponse
(String certificateName) Deletes the creation operation for the specified certificate that is in the process of being created.com.azure.core.http.rest.PagedFlux
<CertificateContact> Deletes the certificate contacts in the key vault.deleteIssuer
(String issuerName) Deletes the specified certificate issuer.Mono
<com.azure.core.http.rest.Response<CertificateIssuer>> deleteIssuerWithResponse
(String issuerName) Deletes the specified certificate issuer.getCertificate
(String certificateName) Gets information about the latest version of the specified certificate.com.azure.core.util.polling.PollerFlux
<CertificateOperation, KeyVaultCertificateWithPolicy> getCertificateOperation
(String certificateName) Gets a pendingCertificateOperation
from the key vault.getCertificatePolicy
(String certificateName) Retrieves the policy of the specified certificate in the key vault.Mono
<com.azure.core.http.rest.Response<CertificatePolicy>> getCertificatePolicyWithResponse
(String certificateName) Retrieves the policy of the specified certificate in the key vault.getCertificateVersion
(String certificateName, String version) Gets information about the specified version of the specified certificate.Mono
<com.azure.core.http.rest.Response<KeyVaultCertificate>> getCertificateVersionWithResponse
(String certificateName, String version) Gets information about the latest version of the specified certificate.Mono
<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> getCertificateWithResponse
(String certificateName) Gets information about the latest version of the specified certificate.getDeletedCertificate
(String certificateName) Retrieves information about the specified deleted certificate.Mono
<com.azure.core.http.rest.Response<DeletedCertificate>> getDeletedCertificateWithResponse
(String certificateName) Retrieves information about the specified deleted certificate.Retrieves the specified certificate issuer from the key vault.Mono
<com.azure.core.http.rest.Response<CertificateIssuer>> getIssuerWithResponse
(String issuerName) Retrieves the specified certificate issuer from the key vault.Get the vault endpoint url to which service requests are sent to.importCertificate
(ImportCertificateOptions importCertificateOptions) Imports an existing valid certificate, containing a private key, into Azure Key Vault.Mono
<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> importCertificateWithResponse
(ImportCertificateOptions importCertificateOptions) Imports a pre-existing certificate to the key vault.com.azure.core.http.rest.PagedFlux
<CertificateContact> Lists the certificate contacts in the key vault.com.azure.core.http.rest.PagedFlux
<DeletedCertificate> Lists thedeleted certificates
in the key vault currently available for recovery.com.azure.core.http.rest.PagedFlux
<DeletedCertificate> listDeletedCertificates
(boolean includePending) Lists thedeleted certificates
in the key vault currently available for recovery.com.azure.core.http.rest.PagedFlux
<CertificateProperties> List certificates in a key vault.com.azure.core.http.rest.PagedFlux
<CertificateProperties> listPropertiesOfCertificates
(boolean includePending) List certificates in the key vault.com.azure.core.http.rest.PagedFlux
<CertificateProperties> listPropertiesOfCertificateVersions
(String certificateName) List all versions of the specified certificate.com.azure.core.http.rest.PagedFlux
<IssuerProperties> List all the certificate issuers resources in the key vault.mergeCertificate
(MergeCertificateOptions mergeCertificateOptions) Merges a certificate or a certificate chain with a key pair currently available in the service.Mono
<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> mergeCertificateWithResponse
(MergeCertificateOptions mergeCertificateOptions) Merges a certificate or a certificate chain with a key pair currently available in the service.purgeDeletedCertificate
(String certificateName) Permanently deletes the specified deleted certificate without possibility for recovery.purgeDeletedCertificateWithResponse
(String certificateName) Permanently deletes the specified deleted certificate without possibility for recovery.restoreCertificateBackup
(byte[] backup) Restores a backed up certificate to the vault.Mono
<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> restoreCertificateBackupWithResponse
(byte[] backup) Restores a backed up certificate to the vault.com.azure.core.http.rest.PagedFlux
<CertificateContact> setContacts
(List<CertificateContact> contacts) Sets the certificate contacts on the key vault.updateCertificatePolicy
(String certificateName, CertificatePolicy policy) Updates the policy for a certificate.Mono
<com.azure.core.http.rest.Response<CertificatePolicy>> updateCertificatePolicyWithResponse
(String certificateName, CertificatePolicy policy) Updates the policy for a certificate.updateCertificateProperties
(CertificateProperties properties) Updates the specified attributes associated with the specified certificate.Mono
<com.azure.core.http.rest.Response<KeyVaultCertificate>> Updates the specified attributes associated with the specified certificate.updateIssuer
(CertificateIssuer issuer) Updates the specified certificate issuer.Mono
<com.azure.core.http.rest.Response<CertificateIssuer>> Updates the specified certificate issuer.
-
Method Details
-
getVaultUrl
Get the vault endpoint url to which service requests are sent to.- Returns:
- the vault endpoint url
-
beginCreateCertificate
public com.azure.core.util.polling.PollerFlux<CertificateOperation,KeyVaultCertificateWithPolicy> beginCreateCertificate(String certificateName, CertificatePolicy policy, Boolean isEnabled, Map<String, String> tags) Creates a new certificate. If this is the first version, the certificate resource is created. This operation requires the certificates/create permission.Code Samples
Create certificate is a long running operation. The
poller
allows users to automatically poll on the create certificate operation status. It is possible to monitor each intermediate poll response during the poll operation.CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); Map<String, String> tags = new HashMap<>(); tags.put("foo", "bar"); certificateAsyncClient.beginCreateCertificate("certificateName", policy, true, tags) .subscribe(pollResponse -> { System.out.println("---------------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); System.out.println(pollResponse.getValue().getStatus()); System.out.println(pollResponse.getValue().getStatusDetails()); });
- Parameters:
certificateName
- The name of the certificate to be created.policy
- The policy of the certificate to be created.isEnabled
- The enabled status for the certificate.tags
- The application specific metadata to set.- Returns:
- A
PollerFlux
polling on the create certificate operation status. - Throws:
NullPointerException
- ifpolicy
is null.com.azure.core.exception.ResourceModifiedException
- when invalid certificate policy configuration is provided.
-
beginCreateCertificate
public com.azure.core.util.polling.PollerFlux<CertificateOperation,KeyVaultCertificateWithPolicy> beginCreateCertificate(String certificateName, CertificatePolicy policy) Creates a new certificate. If this is the first version, the certificate resource is created. This operation requires the certificates/create permission.Code Samples
Create certificate is a long running operation. The
poller
allows users to automatically poll on the create certificate operation status. It is possible to monitor each intermediate poll response during the poll operation.CertificatePolicy certPolicy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); certificateAsyncClient.beginCreateCertificate("certificateName", certPolicy) .subscribe(pollResponse -> { System.out.println("---------------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); System.out.println(pollResponse.getValue().getStatus()); System.out.println(pollResponse.getValue().getStatusDetails()); });
- Parameters:
certificateName
- The name of the certificate to be created.policy
- The policy of the certificate to be created.- Returns:
- A
PollerFlux
polling on the create certificate operation status. - Throws:
NullPointerException
- ifpolicy
is null.com.azure.core.exception.ResourceModifiedException
- when invalid certificate policy configuration is provided.
-
getCertificateOperation
public com.azure.core.util.polling.PollerFlux<CertificateOperation,KeyVaultCertificateWithPolicy> getCertificateOperation(String certificateName) Gets a pendingCertificateOperation
from the key vault. This operation requires the certificates/get permission.Code Samples
Get a pending certificate operation. The
poller
allows users to automatically poll on the certificate operation status. It is possible to monitor each intermediate poll response during the poll operation.certificateAsyncClient.getCertificateOperation("certificateName") .subscribe(pollResponse -> { System.out.println("---------------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); System.out.println(pollResponse.getValue().getStatus()); System.out.println(pollResponse.getValue().getStatusDetails()); });
- Parameters:
certificateName
- The name of the certificate.- Returns:
- A
PollerFlux
polling on the certificate operation status. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate operation for a certificate withcertificateName
doesn't exist.
-
getCertificate
Gets information about the latest version of the specified certificate. This operation requires the certificates/get permission.Code Samples
Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
certificateAsyncClient.getCertificate("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateResponse -> System.out.printf("Certificate is returned with name %s and secretId %s %n", certificateResponse.getProperties().getName(), certificateResponse.getSecretId()));
- Parameters:
certificateName
- The name of the certificate to retrieve, cannot be null- Returns:
- A
Mono
containing the requestedcertificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifcertificateName
is empty string.
-
getCertificateWithResponse
public Mono<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> getCertificateWithResponse(String certificateName) Gets information about the latest version of the specified certificate. This operation requires the certificates/get permission.Code Samples
Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
certificateAsyncClient.getCertificateWithResponse("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateResponse -> System.out.printf("Certificate is returned with name %s and secretId %s %n", certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getSecretId()));
- Parameters:
certificateName
- The name of the certificate to retrieve, cannot be null- Returns:
- A
Mono
containing aResponse
whosevalue
contains the requestedcertificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifcertificateName
is empty string.
-
getCertificateVersionWithResponse
public Mono<com.azure.core.http.rest.Response<KeyVaultCertificate>> getCertificateVersionWithResponse(String certificateName, String version) Gets information about the latest version of the specified certificate. This operation requires the certificates/get permission.Code Samples
Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
String certificateVersion = "6A385B124DEF4096AF1361A85B16C204"; certificateAsyncClient.getCertificateVersionWithResponse("certificateName", certificateVersion) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateWithVersion -> System.out.printf("Certificate is returned with name %s and secretId %s %n", certificateWithVersion.getValue().getProperties().getName(), certificateWithVersion.getValue().getSecretId()));
- Parameters:
certificateName
- The name of the certificate to retrieve, cannot be nullversion
- The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved.- Returns:
- A
Mono
containing aResponse
whosevalue
contains the requestedcertificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifcertificateName
is empty string.
-
getCertificateVersion
Gets information about the specified version of the specified certificate. This operation requires the certificates/get permission.Code Samples
Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.
certificateAsyncClient.getCertificateVersion("certificateName", certificateVersion) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateWithVersion -> System.out.printf("Certificate is returned with name %s and secretId %s %n", certificateWithVersion.getProperties().getName(), certificateWithVersion.getSecretId()));
- Parameters:
certificateName
- The name of the certificate to retrieve, cannot be nullversion
- The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved.- Returns:
- A
Mono
containing the requestedcertificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifcertificateName
is empty string.
-
updateCertificateProperties
Updates the specified attributes associated with the specified certificate. The update operation changes specified attributes of an existing stored certificate and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.Code Samples
Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure Key Vault. Prints out the returned certificate details when a response has been received.
certificateAsyncClient.getCertificate("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateResponseValue -> { KeyVaultCertificate certificate = certificateResponseValue; //Update enabled status of the certificate certificate.getProperties().setEnabled(false); certificateAsyncClient.updateCertificateProperties(certificate.getProperties()) .subscribe(certificateResponse -> System.out.printf("Certificate's enabled status %s %n", certificateResponse.getProperties().isEnabled().toString())); });
- Parameters:
properties
- TheCertificateProperties
object with updated properties.- Returns:
- A
Mono
containing theupdated certificate
. - Throws:
NullPointerException
- ifproperties
is null.com.azure.core.exception.ResourceNotFoundException
- when a certificate withname
andversion
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifname
orversion
is empty string.
-
updateCertificatePropertiesWithResponse
public Mono<com.azure.core.http.rest.Response<KeyVaultCertificate>> updateCertificatePropertiesWithResponse(CertificateProperties properties) Updates the specified attributes associated with the specified certificate. The update operation changes specified attributes of an existing stored certificate and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.Code Samples
Gets latest version of the certificate, changes its enabled status and then updates it in the Azure Key Vault. Prints out the returned certificate details when a response has been received.
certificateAsyncClient.getCertificate("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateResponseValue -> { KeyVaultCertificate certificate = certificateResponseValue; //Update the enabled status of the certificate. certificate.getProperties().setEnabled(false); certificateAsyncClient.updateCertificatePropertiesWithResponse(certificate.getProperties()) .subscribe(certificateResponse -> System.out.printf("Certificate's enabled status %s %n", certificateResponse.getValue().getProperties().isEnabled().toString())); });
- Parameters:
properties
- TheCertificateProperties
object with updated properties.- Returns:
- A
Mono
containing aResponse
whosevalue
contains theupdated certificate
. - Throws:
NullPointerException
- ifproperties
is null.com.azure.core.exception.ResourceNotFoundException
- when a certificate withname
andversion
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifname
orversion
is empty string.
-
beginDeleteCertificate
public com.azure.core.util.polling.PollerFlux<DeletedCertificate,Void> beginDeleteCertificate(String certificateName) Deletes a certificate from a specified key vault. All the versions of the certificate along with its associated policy get deleted. If soft-delete is enabled on the key vault then the certificate is placed in the deleted state and requires to be purged for permanent deletion else the certificate is permanently deleted. The delete operation applies to any certificate stored in Azure Key Vault, but it cannot be applied to an individual version of a certificate. This operation requires the certificates/delete permission.Code Samples
Deletes the certificate in the Azure Key Vault. Prints out the deleted certificate details when a response has been received.
certificateAsyncClient.beginDeleteCertificate("certificateName") .subscribe(pollResponse -> { System.out.println("Delete Status: " + pollResponse.getStatus().toString()); System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); });
- Parameters:
certificateName
- The name of the certificate to be deleted.- Returns:
- A
PollerFlux
to poll on thedeleted certificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
getDeletedCertificate
Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the certificates/get permission.Code Samples
Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate details when a response has been received.
certificateAsyncClient.getDeletedCertificate("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(deletedSecretResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedSecretResponse.getRecoveryId()));
- Parameters:
certificateName
- The name of the deleted certificate.- Returns:
- A
Mono
containing thedeleted certificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
getDeletedCertificateWithResponse
public Mono<com.azure.core.http.rest.Response<DeletedCertificate>> getDeletedCertificateWithResponse(String certificateName) Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the certificates/get permission.Code Samples
Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate details when a response has been received.
certificateAsyncClient.getDeletedCertificateWithResponse("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(deletedSecretResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedSecretResponse.getValue().getRecoveryId()));
- Parameters:
certificateName
- The name of the deleted certificate.- Returns:
- A
Mono
containing aResponse
whosevalue
contains thedeleted certificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
purgeDeletedCertificate
Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level does not specify 'Purgeable'. This operation requires the certificate/purge permission.Code Samples
Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the server response when a response has been received.
certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(purgeResponse -> System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode()));
- Parameters:
certificateName
- The name of the deleted certificate.- Returns:
- An empty
Mono
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
purgeDeletedCertificateWithResponse
public Mono<com.azure.core.http.rest.Response<Void>> purgeDeletedCertificateWithResponse(String certificateName) Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level does not specify 'Purgeable'. This operation requires the certificate/purge permission.Code Samples
Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the server response when a response has been received.
certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(purgeResponse -> System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode()));
- Parameters:
certificateName
- The name of the deleted certificate.- Returns:
- A
Mono
containing a Void Response}. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
beginRecoverDeletedCertificate
public com.azure.core.util.polling.PollerFlux<KeyVaultCertificateWithPolicy,Void> beginRecoverDeletedCertificate(String certificateName) Recovers the deleted certificate back to its current version under /certificates and can only be performed on a soft-delete enabled vault. The RecoverDeletedCertificate operation performs the reversal of the Delete operation and must be issued during the retention interval (available in the deleted certificate's attributes). This operation requires the certificates/recover permission.Code Samples
Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the recovered certificate details when a response has been received.
certificateAsyncClient.beginRecoverDeletedCertificate("deletedCertificateName") .subscribe(pollResponse -> { System.out.println("Recovery Status: " + pollResponse.getStatus().toString()); System.out.println("Recover Certificate Name: " + pollResponse.getValue().getName()); System.out.println("Recover Certificate Id: " + pollResponse.getValue().getId()); });
- Parameters:
certificateName
- The name of the deleted certificate to be recovered.- Returns:
- A
PollerFlux
to poll on therecovered certificate
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the certificate vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
backupCertificate
Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission.Code Samples
Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array returned in the response.
certificateAsyncClient.backupCertificate("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateBackupResponse -> System.out.printf("Certificate's Backup Byte array's length %s %n", certificateBackupResponse.length));
- Parameters:
certificateName
- The name of the certificate.- Returns:
- A
Mono
containing the backed up certificate blob. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
backupCertificateWithResponse
public Mono<com.azure.core.http.rest.Response<byte[]>> backupCertificateWithResponse(String certificateName) Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission.Code Samples
Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array returned in the response.
certificateAsyncClient.backupCertificateWithResponse("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateBackupResponse -> System.out.printf("Certificate's Backup Byte array's length %s %n", certificateBackupResponse.getValue().length));
- Parameters:
certificateName
- The name of the certificate.- Returns:
- A
Mono
containing aResponse
whosevalue
contains the backed up certificate blob. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
restoreCertificateBackup
Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. This operation requires the certificates/restore permission.Code Samples
Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a response has been received.
byte[] certificateBackupByteArray = {}; certificateAsyncClient.restoreCertificateBackup(certificateBackupByteArray) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", certificateResponse.getProperties().getName(), certificateResponse.getKeyId()));
- Parameters:
backup
- The backup blob associated with the certificate.- Returns:
- A
Mono
containing therestored certificate
. - Throws:
com.azure.core.exception.ResourceModifiedException
- whenbackup
blob is malformed.
-
restoreCertificateBackupWithResponse
public Mono<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> restoreCertificateBackupWithResponse(byte[] backup) Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. This operation requires the certificates/restore permission.Code Samples
Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a response has been received.
byte[] certificateBackup = {}; certificateAsyncClient.restoreCertificateBackup(certificateBackup) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", certificateResponse.getProperties().getName(), certificateResponse.getKeyId()));
- Parameters:
backup
- The backup blob associated with the certificate.- Returns:
- A
Mono
containing aResponse
whosevalue
contains therestored certificate
. - Throws:
com.azure.core.exception.ResourceModifiedException
- whenbackup
blob is malformed.
-
listPropertiesOfCertificates
public com.azure.core.http.rest.PagedFlux<CertificateProperties> listPropertiesOfCertificates(boolean includePending) List certificates in the key vault. Retrieves the set of certificates resources in the key vault and the individual certificate response in the flux is represented byCertificateProperties
as only the certificate identifier, thumbprint, attributes and tags are provided in the response. The policy and individual certificate versions are not listed in the response. This operation requires the certificates/list permission.It is possible to get certificates with all the properties excluding the policy from this information. Convert the
Flux
containingCertificateProperties
toFlux
containingcertificate
usinggetCertificateVersion(String, String)
withinFlux.flatMap(Function)
.certificateAsyncClient.listPropertiesOfCertificates() .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), certificate.getVersion()) .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", certificateResponse.getName(), certificateResponse.getKeyId())));
- Parameters:
includePending
- indicate if pending certificates should be included in the results.- Returns:
- A
PagedFlux
containingcertificate
for all the certificates in the vault.
-
listPropertiesOfCertificates
List certificates in a key vault. Retrieves the set of certificates resources in the key vault and the individual certificate response in the flux is represented byCertificateProperties
as only the certificate identifier, thumbprint, attributes and tags are provided in the response. The policy and individual certificate versions are not listed in the response. This operation requires the certificates/list permission.It is possible to get certificates with all the properties excluding the policy from this information. Convert the
Flux
containingCertificateProperties
toFlux
containingcertificate
usinggetCertificateVersion(String, String)
withinFlux.flatMap(Function)
.certificateAsyncClient.listPropertiesOfCertificates() .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), certificate.getVersion()) .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", certificateResponse.getName(), certificateResponse.getKeyId())));
- Returns:
- A
PagedFlux
containingcertificate
for all the certificates in the vault.
-
listDeletedCertificates
Lists thedeleted certificates
in the key vault currently available for recovery. This operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This operation requires the certificates/get/list permission.Code Samples
Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a response has been received.
certificateAsyncClient.listDeletedCertificates() .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(deletedCertificateResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedCertificateResponse.getRecoveryId()));
- Returns:
- A
PagedFlux
containing all of thedeleted certificates
in the vault.
-
listDeletedCertificates
public com.azure.core.http.rest.PagedFlux<DeletedCertificate> listDeletedCertificates(boolean includePending) Lists thedeleted certificates
in the key vault currently available for recovery. This operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This operation requires the certificates/get/list permission.Code Samples
Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a response has been received.
certificateAsyncClient.listDeletedCertificates() .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(deletedCertificateResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedCertificateResponse.getRecoveryId()));
- Parameters:
includePending
- indicate if pending deleted certificates should be included in the results.- Returns:
- A
PagedFlux
containing all of thedeleted certificates
in the vault.
-
listPropertiesOfCertificateVersions
public com.azure.core.http.rest.PagedFlux<CertificateProperties> listPropertiesOfCertificateVersions(String certificateName) List all versions of the specified certificate. The individual certificate response in the flux is represented byCertificateProperties
as only the certificate identifier, thumbprint, attributes and tags are provided in the response. The policy is not listed in the response. This operation requires the certificates/list permission.It is possible to get the certificates with properties excluding the policy for all the versions from this information. Convert the
PagedFlux
containingCertificateProperties
toPagedFlux
containingcertificate
usinggetCertificateVersion(String, String)
withinFlux.flatMap(Function)
.certificateAsyncClient.listPropertiesOfCertificateVersions("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), certificate.getVersion()) .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", certificateResponse.getProperties().getName(), certificateResponse.getKeyId())));
- Parameters:
certificateName
- The name of the certificate.- Returns:
- A
PagedFlux
containingcertificate
of all the versions of the specified certificate in the vault. Flux is empty if certificate withcertificateName
does not exist in key vault. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate withcertificateName
is empty string.
-
mergeCertificate
Merges a certificate or a certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.Code Samples
Merges a certificate with a kay pair available in the service.
List<byte[]> x509CertificatesToMerge = new ArrayList<>(); MergeCertificateOptions config = new MergeCertificateOptions("certificateName", x509CertificatesToMerge).setEnabled(false); certificateAsyncClient.mergeCertificate(config) .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s", certificate.getProperties().getName(), certificate.getKeyId()));
- Parameters:
mergeCertificateOptions
- the merge certificate options holding the x509 certificates.- Returns:
- A
Mono
containing the merged certificate. - Throws:
NullPointerException
- whenmergeCertificateOptions
is null.com.azure.core.exception.HttpResponseException
- ifmergeCertificateOptions
is invalid/corrupt.
-
mergeCertificateWithResponse
public Mono<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> mergeCertificateWithResponse(MergeCertificateOptions mergeCertificateOptions) Merges a certificate or a certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.Code Samples
Merges a certificate with a kay pair available in the service.
List<byte[]> x509CertsToMerge = new ArrayList<>(); MergeCertificateOptions mergeConfig = new MergeCertificateOptions("certificateName", x509CertsToMerge).setEnabled(false); certificateAsyncClient.mergeCertificateWithResponse(mergeConfig) .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s", certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId()));
- Parameters:
mergeCertificateOptions
- the merge certificate options holding the x509 certificates.- Returns:
- A
Mono
containing aResponse
whosevalue
contains the merged certificate. - Throws:
NullPointerException
- whenmergeCertificateOptions
is null.com.azure.core.exception.HttpResponseException
- ifmergeCertificateOptions
is invalid/corrupt.
-
getCertificatePolicy
Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get permission.Code Samples
Gets the policy of a certificate in the key vault. Prints out the returned certificate policy details when a response has been received.
certificateAsyncClient.getCertificatePolicy("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(policy -> System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n", policy.getIssuerName(), policy.getSubject()));
- Parameters:
certificateName
- The name of the certificate whose policy is to be retrieved, cannot be null- Returns:
- A
Mono
containing aResponse
whosevalue
contains the requestedcertificate policy
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifcertificateName
is empty string.
-
getCertificatePolicyWithResponse
public Mono<com.azure.core.http.rest.Response<CertificatePolicy>> getCertificatePolicyWithResponse(String certificateName) Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get permission.Code Samples
Gets the policy of a certificate in the key vault. Prints out the returned certificate policy details when a response has been received.
certificateAsyncClient.getCertificatePolicyWithResponse("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(policyResponse -> System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n", policyResponse.getValue().getIssuerName(), policyResponse.getValue().getSubject()));
- Parameters:
certificateName
- The name of the certificate whose policy is to be retrieved, cannot be null- Returns:
- A
Mono
containing the requestedcertificate policy
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifcertificateName
is empty string.
-
updateCertificatePolicy
public Mono<CertificatePolicy> updateCertificatePolicy(String certificateName, CertificatePolicy policy) Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.Code Samples
Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the returned policy details when a response has been received.
certificateAsyncClient.getCertificatePolicy("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificatePolicyResponseValue -> { CertificatePolicy certificatePolicy = certificatePolicyResponseValue; // Update transparency certificatePolicy.setCertificateTransparent(true); certificateAsyncClient.updateCertificatePolicy("certificateName", certificatePolicy) .subscribe(updatedPolicy -> System.out.printf("Certificate policy's updated transparency status %s %n", updatedPolicy.isCertificateTransparent())); });
- Parameters:
certificateName
- The name of the certificate whose policy is to be updated.policy
- The certificate policy to be updated.- Returns:
- A
Mono
containing the updatedcertificate policy
. - Throws:
NullPointerException
- ifpolicy
is null.com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifcertificateName
is empty string or ifpolicy
is invalid.
-
updateCertificatePolicyWithResponse
public Mono<com.azure.core.http.rest.Response<CertificatePolicy>> updateCertificatePolicyWithResponse(String certificateName, CertificatePolicy policy) Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.Code Samples
Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the returned policy details when a response has been received.
certificateAsyncClient.getCertificatePolicy("certificateName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(certificatePolicyResponseValue -> { CertificatePolicy certificatePolicy = certificatePolicyResponseValue; // Update transparency certificatePolicy.setCertificateTransparent(true); certificateAsyncClient.updateCertificatePolicyWithResponse("certificateName", certificatePolicy) .subscribe(updatedPolicyResponse -> System.out.printf("Certificate policy's updated transparency status %s %n", updatedPolicyResponse.getValue().isCertificateTransparent())); });
- Parameters:
certificateName
- The name of the certificate whose policy is to be updated.policy
- The certificate policy is to be updated.- Returns:
- A
Mono
containing aResponse
whosevalue
contains the updatedcertificate policy
. - Throws:
NullPointerException
- ifpolicy
is null.com.azure.core.exception.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifname
is empty string or ifpolicy
is invalid.
-
createIssuer
Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate issuer if it already exists or adds it if it doesn't exist. This operation requires the certificates/setissuers permission.Code Samples
Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a response has been received.
CertificateIssuer issuer = new CertificateIssuer("issuerName", "providerName") .setAccountId("keyvaultuser") .setPassword("fakePasswordPlaceholder"); certificateAsyncClient.createIssuer(issuer) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(issuerResponse -> { System.out.printf("Issuer created with %s and %s", issuerResponse.getName(), issuerResponse.getProvider()); });
- Parameters:
issuer
- The configuration of the certificate issuer to be created.- Returns:
- A
Mono
containing the createdcertificate issuer
. - Throws:
NullPointerException
- ifissuer
is null.com.azure.core.exception.ResourceModifiedException
- when invalid certificate issuerissuer
configuration is provided.com.azure.core.exception.HttpResponseException
- when a certificate issuer withissuerName
is empty string.
-
createIssuerWithResponse
public Mono<com.azure.core.http.rest.Response<CertificateIssuer>> createIssuerWithResponse(CertificateIssuer issuer) Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate issuer if it already exists or adds it if it doesn't exist. This operation requires the certificates/setissuers permission.Code Samples
Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a response has been received.
CertificateIssuer newIssuer = new CertificateIssuer("issuerName", "providerName") .setAccountId("keyvaultuser") .setPassword("fakePasswordPlaceholder"); certificateAsyncClient.createIssuerWithResponse(newIssuer) .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(issuerResponse -> { System.out.printf("Issuer created with %s and %s", issuerResponse.getValue().getName(), issuerResponse.getValue().getProvider()); });
- Parameters:
issuer
- The configuration of the certificate issuer to be created. UseCertificateIssuer(String, String)
to initialize the issuer object- Returns:
- A
Mono
containing aResponse
whosevalue
contains the createdcertificate issuer
. - Throws:
NullPointerException
- ifissuer
is null.com.azure.core.exception.ResourceModifiedException
- when invalid certificate issuerissuer
configuration is provided.com.azure.core.exception.HttpResponseException
- when a certificate issuer withname
is empty string.
-
getIssuerWithResponse
public Mono<com.azure.core.http.rest.Response<CertificateIssuer>> getIssuerWithResponse(String issuerName) Retrieves the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/getissuers permission.Code Samples
Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details when a response has been received.
certificateAsyncClient.getIssuerWithResponse("issuerName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(issuerResponse -> { System.out.printf("Issuer returned with %s and %s", issuerResponse.getValue().getName(), issuerResponse.getValue().getProvider()); });
- Parameters:
issuerName
- The name of the certificate issuer to retrieve, cannot be null- Returns:
- A
Mono
containing aResponse
whosevalue
contains the requestedcertificate issuer
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate issuer withissuerName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifissuerName
is empty string.
-
getIssuer
Retrieves the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/getissuers permission.Code Samples
Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details when a response has been received.
certificateAsyncClient.getIssuer("issuerName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(issuer -> { System.out.printf("Issuer returned with %s and %s", issuer.getName(), issuer.getProvider()); });
- Parameters:
issuerName
- The name of the certificate to retrieve, cannot be null- Returns:
- A
Mono
containing the requestedcertificate issuer
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate issuer withissuerName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifissuerName
is empty string.
-
deleteIssuerWithResponse
public Mono<com.azure.core.http.rest.Response<CertificateIssuer>> deleteIssuerWithResponse(String issuerName) Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers permission.Code Samples
Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a response has been received.
certificateAsyncClient.deleteIssuerWithResponse("issuerName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(deletedIssuerResponse -> System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getValue().getName()));
- Parameters:
issuerName
- The name of the certificate issuer to be deleted.- Returns:
- A
Mono
containing aResponse
whosevalue
contains thedeleted issuer
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate issuer withissuerName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate issuer withissuerName
is empty string.
-
deleteIssuer
Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers permission.Code Samples
Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a response has been received.
certificateAsyncClient.deleteIssuer("issuerName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(deletedIssuerResponse -> System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getName()));
- Parameters:
issuerName
- The name of the certificate issuer to be deleted.- Returns:
- A
Mono
containing thedeleted issuer
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate issuer withissuerName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when a certificate issuer withissuerName
is empty string.
-
listPropertiesOfIssuers
List all the certificate issuers resources in the key vault. The individual certificate issuer response in the flux is represented byIssuerProperties
as only the certificate issuer identifier and provider are provided in the response. This operation requires the certificates/manageissuers/getissuers permission.It is possible to get the certificate issuer with all of its properties from this information. Convert the
PagedFlux
containingissuerProperties
toPagedFlux
containingissuer
usinggetIssuer(String)
certificateAsyncClient.listPropertiesOfIssuers() .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(issuerProperties -> certificateAsyncClient.getIssuer(issuerProperties.getName()) .subscribe(issuerResponse -> System.out.printf("Received issuer with name %s and provider %s", issuerResponse.getName(), issuerResponse.getProvider())));
- Returns:
- A
PagedFlux
containing all of thecertificate issuers
in the vault.
-
updateIssuer
Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes of the certificate issuer entity. This operation requires the certificates/setissuers permission.Code Samples
Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the returned certificate issuer details when a response has been received.
certificateAsyncClient.getIssuer("issuerName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(issuerResponseValue -> { CertificateIssuer issuer = issuerResponseValue; //Update the enabled status of the issuer. issuer.setEnabled(false); certificateAsyncClient.updateIssuer(issuer) .subscribe(issuerResponse -> System.out.printf("Issuer's enabled status %s %n", issuerResponse.isEnabled().toString())); });
- Parameters:
issuer
- Theissuer
with updated properties. UseCertificateIssuer(String)
to initialize the issuer object- Returns:
- A
Mono
containing theupdated issuer
. - Throws:
NullPointerException
- ifissuer
is null.com.azure.core.exception.ResourceNotFoundException
- when a certificate issuer withname
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifname
is empty string.
-
updateIssuerWithResponse
public Mono<com.azure.core.http.rest.Response<CertificateIssuer>> updateIssuerWithResponse(CertificateIssuer issuer) Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes of the certificate issuer entity. This operation requires the certificates/setissuers permission.Code Samples
Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the returned certificate issuer details when a response has been received.
certificateAsyncClient.getIssuer("issuerName") .contextWrite(Context.of(key1, value1, key2, value2)) .subscribe(issuerResponseValue -> { CertificateIssuer issuer = issuerResponseValue; //Update the enabled status of the issuer. issuer.setEnabled(false); certificateAsyncClient.updateIssuer(issuer) .subscribe(issuerResponse -> System.out.printf("Issuer's enabled status %s %n", issuerResponse.isEnabled().toString())); });
- Parameters:
issuer
- Theissuer
with updated properties.- Returns:
- A
Mono
containing aResponse
whosevalue
contains theupdated issuer
. - Throws:
NullPointerException
- ifissuer
is null.com.azure.core.exception.ResourceNotFoundException
- when a certificate issuer withname
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- ifname
is empty string.
-
setContacts
public com.azure.core.http.rest.PagedFlux<CertificateContact> setContacts(List<CertificateContact> contacts) Sets the certificate contacts on the key vault. This operation requires the certificates/managecontacts permission.The
LifetimeAction
of typeCertificatePolicyAction.EMAIL_CONTACTS
set on aCertificatePolicy
emails the contacts set on the vault when triggered.Code Samples
Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.
CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); certificateAsyncClient.setContacts(Collections.singletonList(contactToAdd)).subscribe(contact -> System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail()) );
- Parameters:
contacts
- The list of contacts to set on the vault.- Returns:
- A
PagedFlux
containing all of thecertificate contacts
in the vault. - Throws:
com.azure.core.exception.HttpResponseException
- when a contact information provided is invalid/incomplete.
-
listContacts
Lists the certificate contacts in the key vault. This operation requires the certificates/managecontacts permission.Code Samples
Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.
certificateAsyncClient.listContacts().subscribe(contact -> System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail()) );
- Returns:
- A
PagedFlux
containing all of thecertificate contacts
in the vault.
-
deleteContacts
Deletes the certificate contacts in the key vault. This operation requires the certificates/managecontacts permission.Code Samples
Deletes the certificate contacts in the Azure Key Vault. Prints out the deleted contacts details.
certificateAsyncClient.deleteContacts().subscribe(contact -> System.out.printf("Deleted Contact name %s and email %s", contact.getName(), contact.getEmail()) );
- Returns:
- A
PagedFlux
containing all of thedeleted certificate contacts
in the vault.
-
deleteCertificateOperation
Deletes the creation operation for the specified certificate that is in the process of being created. The certificate is no longer created. This operation requires the certificates/update permission.Code Samples
Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Prints out the deleted certificate operation details when a response has been received.
certificateAsyncClient.deleteCertificateOperation("certificateName") .subscribe(certificateOperation -> System.out.printf("Deleted Certificate operation last status %s", certificateOperation.getStatus()));
- Parameters:
certificateName
- The name of the certificate which is in the process of being created.- Returns:
- A
Mono
containing aResponse
whosevalue
contains thedeleted certificate operation
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate operation for a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when thecertificateName
is empty string.
-
deleteCertificateOperationWithResponse
public Mono<com.azure.core.http.rest.Response<CertificateOperation>> deleteCertificateOperationWithResponse(String certificateName) Deletes the creation operation for the specified certificate that is in the process of being created. The certificate is no longer created. This operation requires the certificates/update permission.Code Samples
Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Prints out the deleted certificate operation details when a response has been received.
certificateAsyncClient.deleteCertificateOperationWithResponse("certificateName") .subscribe(certificateOperationResponse -> System.out.printf("Deleted Certificate operation's last" + " status %s", certificateOperationResponse.getValue().getStatus()));
- Parameters:
certificateName
- The name of the certificate which is in the process of being created.- Returns:
- A
Mono
containing thedeleted certificate operation
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate operation for a certificate withcertificateName
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when thecertificateName
is empty string.
-
cancelCertificateOperation
Cancels a certificate creation operation that is already in progress. This operation requires the certificates/update permission.Code Samples
Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Prints out the updated certificate operation details when a response has been received.
certificateAsyncClient.cancelCertificateOperation("certificateName") .subscribe(certificateOperation -> System.out.printf("Certificate operation status %s", certificateOperation.getStatus()));
- Parameters:
certificateName
- The name of the certificate which is in the process of being created.- Returns:
- A
Mono
containing aResponse
whosevalue
contains thecancelled certificate operation
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate operation for a certificate withname
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when thename
is empty string.
-
cancelCertificateOperationWithResponse
public Mono<com.azure.core.http.rest.Response<CertificateOperation>> cancelCertificateOperationWithResponse(String certificateName) Cancels a certificate creation operation that is already in progress. This operation requires the certificates/update permission.Code Samples
Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Prints out the updated certificate operation details when a response has been received.
certificateAsyncClient.cancelCertificateOperationWithResponse("certificateName") .subscribe(certificateOperationResponse -> System.out.printf("Certificate operation status %s", certificateOperationResponse.getValue().getStatus()));
- Parameters:
certificateName
- The name of the certificate which is in the process of being created.- Returns:
- A
Mono
containing aResponse
whosevalue
contains thecancelled certificate operation
. - Throws:
com.azure.core.exception.ResourceNotFoundException
- when a certificate operation for a certificate withname
doesn't exist in the key vault.com.azure.core.exception.HttpResponseException
- when thename
is empty string.
-
importCertificate
public Mono<KeyVaultCertificateWithPolicy> importCertificate(ImportCertificateOptions importCertificateOptions) Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires the certificates/import permission. 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. Key Vault will only accept a key in PKCS#8 format.Code Samples
Imports a certificate into the key vault.
byte[] certificateToImport = new byte[100]; ImportCertificateOptions config = new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false); certificateAsyncClient.importCertificate(config) .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s", certificate.getProperties().getName(), certificate.getKeyId()));
- Parameters:
importCertificateOptions
- The details of the certificate to import to the key vault- Returns:
- A
Response
whosevalue
contains theimported certificate
. - Throws:
NullPointerException
- ifimportCertificateOptions
is null.com.azure.core.exception.HttpResponseException
- when theimportCertificateOptions
are invalid.
-
importCertificateWithResponse
public Mono<com.azure.core.http.rest.Response<KeyVaultCertificateWithPolicy>> importCertificateWithResponse(ImportCertificateOptions importCertificateOptions) Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or PEM format, and must contain the private key as well as the x509 certificates. This operation requires the certificates/import permission.Code Samples
Imports a certificate into the key vault.
byte[] certToImport = new byte[100]; ImportCertificateOptions importCertificateOptions = new ImportCertificateOptions("certificateName", certToImport).setEnabled(false); certificateAsyncClient.importCertificateWithResponse(importCertificateOptions) .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s", certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId()));
- Parameters:
importCertificateOptions
- The details of the certificate to import to the key vault- Returns:
- A
Mono
containing aResponse
whosevalue
contains theimported certificate
. - Throws:
NullPointerException
- ifimportCertificateOptions
is null.com.azure.core.exception.HttpResponseException
- when theimportCertificateOptions
are invalid.
-