Class CertificateAsyncClient

java.lang.Object
com.azure.security.keyvault.certificates.CertificateAsyncClient

public final class CertificateAsyncClient extends Object
The CertificateAsyncClient provides asynchronous methods to manage certifcates in the Azure 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 Azure 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

Samples to construct the async client

 CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
     .credential(new DefaultAzureCredentialBuilder().build())
     .vaultUrl("https://myvault.vault.azure.net/")
     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
     .buildAsyncClient();
 
See Also:
  • Method Details

    • getVaultUrl

      public String getVaultUrl()
      Get the vault endpoint url to which service requests are sent to.
      Returns:
      the vault endpoint url
    • beginCreateCertificate

      public 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:
      ResourceModifiedException - when invalid certificate policy configuration is provided.
    • beginCreateCertificate

      public 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:
      ResourceModifiedException - when invalid certificate policy configuration is provided.
    • getCertificateOperation

      public PollerFlux<CertificateOperation,KeyVaultCertificateWithPolicy> getCertificateOperation(String certificateName)
      Gets a pending CertificateOperation 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:
      ResourceNotFoundException - when a certificate operation for a certificate with certificateName doesn't exist.
    • getCertificate

      public Mono<KeyVaultCertificateWithPolicy> getCertificate(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.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 requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if certificateName is empty string.
    • getCertificateWithResponse

      public Mono<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 a Response whose value contains the requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if certificateName is empty string.
    • getCertificateVersionWithResponse

      public Mono<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 null
      version - 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 a Response whose value contains the requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if certificateName is empty string.
    • getCertificateVersion

      public Mono<KeyVaultCertificate> getCertificateVersion(String certificateName, String version)
      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 null
      version - 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 requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if certificateName is empty string.
    • updateCertificateProperties

      public Mono<KeyVaultCertificate> updateCertificateProperties(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 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 - The CertificateProperties object with updated properties.
      Returns:
      A Mono containing the updated certificate.
      Throws:
      NullPointerException - if certificate is null.
      ResourceNotFoundException - when a certificate with name and version doesn't exist in the key vault.
      HttpResponseException - if name or version is empty string.
    • updateCertificatePropertiesWithResponse

      public Mono<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 - The CertificateProperties object with updated properties.
      Returns:
      A Mono containing a Response whose value contains the updated certificate.
      Throws:
      NullPointerException - if properties is null.
      ResourceNotFoundException - when a certificate with name and version doesn't exist in the key vault.
      HttpResponseException - if name or version is empty string.
    • beginDeleteCertificate

      public 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 the deleted certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • getDeletedCertificate

      public Mono<DeletedCertificate> getDeletedCertificate(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.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 the deleted certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • getDeletedCertificateWithResponse

      public Mono<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 a Response whose value contains the deleted certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • purgeDeletedCertificate

      public Mono<Void> purgeDeletedCertificate(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:
      An empty Mono.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • purgeDeletedCertificateWithResponse

      public Mono<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:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • beginRecoverDeletedCertificate

      public 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 the recovered certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the certificate vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • backupCertificate

      public Mono<byte[]> backupCertificate(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.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:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • backupCertificateWithResponse

      public Mono<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 a Response whose value contains the backed up certificate blob.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • restoreCertificateBackup

      public Mono<KeyVaultCertificateWithPolicy> restoreCertificateBackup(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[] 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 the restored certificate.
      Throws:
      ResourceModifiedException - when backup blob is malformed.
    • restoreCertificateBackupWithResponse

      public Mono<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 a Response whose value contains the restored certificate.
      Throws:
      ResourceModifiedException - when backup blob is malformed.
    • listPropertiesOfCertificates

      public PagedFlux<CertificateProperties> listPropertiesOfCertificates(boolean includePending)
      List certificates in a the key vault. Retrieves the set of certificates resources in the key vault and the individual certificate response in the flux is represented by CertificateProperties 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 containing CertificateProperties to Flux containing certificate using getCertificateVersion(String, String) within Flux.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 containing certificate for all the certificates in the vault.
    • listPropertiesOfCertificates

      public PagedFlux<CertificateProperties> listPropertiesOfCertificates()
      List certificates in a the key vault. Retrieves the set of certificates resources in the key vault and the individual certificate response in the flux is represented by CertificateProperties 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 containing CertificateProperties to Flux containing certificate using getCertificateVersion(String, String) within Flux.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 containing certificate for all the certificates in the vault.
    • listDeletedCertificates

      public PagedFlux<DeletedCertificate> listDeletedCertificates()
      Lists the deleted 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 the deleted certificates in the vault.
    • listDeletedCertificates

      public PagedFlux<DeletedCertificate> listDeletedCertificates(boolean includePending)
      Lists the deleted 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 the deleted certificates in the vault.
    • listPropertiesOfCertificateVersions

      public PagedFlux<CertificateProperties> listPropertiesOfCertificateVersions(String certificateName)
      List all versions of the specified certificate. The individual certificate response in the flux is represented by CertificateProperties 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 containing CertificateProperties to PagedFlux containing certificate using getCertificateVersion(String, String) within Flux.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 containing certificate of all the versions of the specified certificate in the vault. Flux is empty if certificate with certificateName does not exist in key vault.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when a certificate with certificateName is empty string.
    • mergeCertificate

      public Mono<KeyVaultCertificate> mergeCertificate(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[]> 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 - when mergeCertificateOptions is null.
      HttpResponseException - if mergeCertificateOptions is invalid/corrupt.
    • mergeCertificateWithResponse

      public Mono<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 a Response whose value contains the merged certificate.
      Throws:
      NullPointerException - when mergeCertificateOptions is null.
      HttpResponseException - if mergeCertificateOptions is invalid/corrupt.
    • getCertificatePolicy

      public Mono<CertificatePolicy> getCertificatePolicy(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 certirifcate 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 a Response whose value contains the requested certificate policy.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if certificateName is empty string.
    • getCertificatePolicyWithResponse

      public Mono<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 certirifcate 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 requested certificate policy.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if certificateName 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 updated certificate policy.
      Throws:
      NullPointerException - if policy is null.
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if certificateName is empty string or if policy is invalid.
    • updateCertificatePolicyWithResponse

      public Mono<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 a Response whose value contains the updated certificate policy.
      Throws:
      NullPointerException - if policy is null.
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - if name is empty string or if policy is invalid.
    • createIssuer

      public Mono<CertificateIssuer> createIssuer(CertificateIssuer issuer)
      Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate issuer if it already exists or adds it if 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("temp2");
       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 created certificate issuer.
      Throws:
      ResourceModifiedException - when invalid certificate issuer issuer configuration is provided.
      HttpResponseException - when a certificate issuer with issuerName is empty string.
    • createIssuerWithResponse

      public Mono<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 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("temp2");
       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. Use CertificateIssuer(String, String) to initialize the issuer object
      Returns:
      A Mono containing a Response whose value contains the created certificate issuer.
      Throws:
      ResourceModifiedException - when invalid certificate issuer issuer configuration is provided.
      HttpResponseException - when a certificate issuer with name is empty string.
    • getIssuerWithResponse

      public Mono<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 specificed certifcate 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 a Response whose value contains the requested certificate issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpResponseException - if issuerName is empty string.
    • getIssuer

      public Mono<CertificateIssuer> getIssuer(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.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 requested certificate issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpResponseException - if issuerName is empty string.
    • deleteIssuerWithResponse

      public Mono<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 a Response whose value contains the deleted issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpResponseException - when a certificate issuer with issuerName is empty string.
    • deleteIssuer

      public Mono<CertificateIssuer> deleteIssuer(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.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 the deleted issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpResponseException - when a certificate issuer with issuerName is empty string.
    • listPropertiesOfIssuers

      public PagedFlux<IssuerProperties> listPropertiesOfIssuers()
      List all the certificate issuers resources in the key vault. The individual certificate issuer response in the flux is represented by IssuerProperties 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 containing issuerProperties to PagedFlux containing issuer using getIssuer(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 the certificate issuers in the vault.
    • updateIssuer

      public Mono<CertificateIssuer> updateIssuer(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 - The issuer with updated properties. Use CertificateIssuer(String) to initialize the issuer object
      Returns:
      A Mono containing the updated issuer.
      Throws:
      NullPointerException - if issuer is null.
      ResourceNotFoundException - when a certificate issuer with name doesn't exist in the key vault.
      HttpResponseException - if name is empty string.
    • updateIssuerWithResponse

      public Mono<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 - The issuer with updated properties.
      Returns:
      A Mono containing a Response whose value contains the updated issuer.
      Throws:
      NullPointerException - if issuer is null.
      ResourceNotFoundException - when a certificate issuer with name doesn't exist in the key vault.
      HttpResponseException - if name is empty string.
    • setContacts

      public PagedFlux<CertificateContact> setContacts(List<CertificateContact> contacts)
      Sets the certificate contacts on the key vault. This operation requires the certificates/managecontacts permission.

      The LifetimeAction of type CertificatePolicyAction.EMAIL_CONTACTS set on a CertificatePolicy 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 the certificate contacts in the vault.
      Throws:
      HttpResponseException - when a contact information provided is invalid/incomplete.
    • listContacts

      public PagedFlux<CertificateContact> 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 the certificate contacts in the vault.
    • deleteContacts

      public PagedFlux<CertificateContact> 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 the deleted certificate contacts in the vault.
    • deleteCertificateOperation

      public Mono<CertificateOperation> deleteCertificateOperation(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.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 a Response whose value contains the deleted certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when the certificateName is empty string.
    • deleteCertificateOperationWithResponse

      public Mono<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 the deleted certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with certificateName doesn't exist in the key vault.
      HttpResponseException - when the certificateName is empty string.
    • cancelCertificateOperation

      public Mono<CertificateOperation> cancelCertificateOperation(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.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 a Response whose value contains the cancelled certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with name doesn't exist in the key vault.
      HttpResponseException - when the name is empty string.
    • cancelCertificateOperationWithResponse

      public Mono<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 a Response whose value contains the cancelled certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with name doesn't exist in the key vault.
      HttpResponseException - when the name 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 whose value contains the imported certificate.
      Throws:
      HttpResponseException - when the importCertificateOptions are invalid.
    • importCertificateWithResponse

      public Mono<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 a Response whose value contains the imported certificate.
      Throws:
      HttpResponseException - when the importCertificateOptions are invalid.