/// <summary>
 /// Updates the vault certificate
 /// </summary>
 /// <param name="certificateRequest">the certificate update arguments</param>
 /// <param name="certificateName">the certificate name.</param>
 /// <returns>Upload Certificate Response</returns>
 public VaultCertificateResponse UpdateVaultCertificate(CertificateRequest certificateRequest, string certificateName)
 {
     return(GetRecoveryServicesClient.VaultCertificates.CreateWithHttpMessagesAsync(
                arsVaultCreds.ResourceGroupName,
                arsVaultCreds.ResourceName,
                certificateName,
                certificateRequest.Properties,
                GetRequestHeaders()).Result.Body);
 }
        /// <summary>
        /// Upload cert to idmgmt
        /// </summary>
        /// <param name="managementCert">certificate to be uploaded</param>
        /// <param name="vault">vault object</param>
        /// <returns>Upload Certificate Response</returns>
        public VaultCertificateResponse UploadCertificate(X509Certificate2 managementCert, ARSVault vault)
        {
            var certificateArgs = new CertificateRequest();

            certificateArgs.Properties             = new RawCertificateData();
            certificateArgs.Properties.Certificate = managementCert.GetRawCertData();
            certificateArgs.Properties.AuthType    = AuthType.AAD;

            return(GetRecoveryServicesClient.VaultCertificates.CreateWithHttpMessagesAsync(
                       vault.ResourceGroupName,
                       vault.Name,
                       managementCert.FriendlyName,
                       certificateArgs.Properties,
                       GetRequestHeaders()).Result.Body);
        }
        /// <summary>
        /// Method to update vault certificate
        /// </summary>
        /// <param name="cert">certificate object.</param>
        /// <param name="authType">authentication method to be used.</param>
        /// <returns>Upload Certificate Response</returns>
        private VaultCertificateResponse UpdateVaultCertificate(
            X509Certificate2 cert,
            string authType)
        {
            var certificateArgs = new CertificateRequest();

            certificateArgs.Properties             = new RawCertificateData();
            certificateArgs.Properties.Certificate = cert.GetRawCertData();
            certificateArgs.Properties.AuthType    = authType;

            VaultCertificateResponse response = this.UpdateVaultCertificate(
                certificateArgs,
                cert.FriendlyName);

            return(response);
        }