|
Azure Key Vault is a cloud service that provides secure storage and automated management of certificates used throughout a cloud application. Multiple certificates, and multiple versions of the same certificate, can be kept in the Azure Key Vault. Each certificate in the vault has a policy associated with it which controls the issuance and lifetime of the certificate, along with actions to be taken as certificates near expiry.
The Azure Key Vault certificates client library enables programmatically managing certificates, offering methods to get certificates, policies, issuers, and contacts.
Source code | API reference documentation | Product documentation
Install the Azure Key Vault certificates client library for C++ with vcpkg:
If you use the Azure CLI, replace <your-resource-group-name>
and <your-key-vault-name>
with your own, unique names:
A KeyVaultCertificate
is the fundamental resource within Azure Key Vault. You'll use certificates to encrypt and verify encrypted or signed data.
With a CertificateClient
you can get certificates from the vault, create new certificates and new versions of existing certificates, update certificate metadata, and delete certificates. You can also manage certificate issuers, contacts, and management policies of certificates. This is illustrated in the examples below.
We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.
Replaceable HTTP transport adapter | Long-running operations |
For detailed samples please review the samples provided.
To create a new CertificateClient
to create, get, update, or delete certificates, you need the endpoint to an Azure Key Vault and credentials.
Key Vault Certificate client for C++ currently supports any TokenCredential
for authenticating.
Then, in the sample below, you can set keyVaultUrl
based on an environment variable, configuration setting, or any way that works for your application.
Call StartCreateCertificate to start creating a new certificate, with specified properties and policy.
Call PollUntilDone to poll the status of the creation. Once the opperation has completed we will call GetCertificate to get the newly created certificate.
Call UpdateCertificateProperties to change one of the certificate properties.
Call StartDeleteCertificate to delete a certificate. This is a long running operation.
If the Azure Key Vault is soft delete-enabled and you want to permanently delete the certificate before its ScheduledPurgeDate
, the certificate needs to be purged.
Call GetPropertiesOfCertificates to retrieve information about certificates from Key Vault.
Repeat the create certificate procedure, for an existing certificate it will create a new version of it.
To get information about certificate versions call GetPropertiesOfCertificateVersions.
Now we will delete the certificates. Since this is a long running operation we need to wait for the operation to finish
After the certificates are deleted , but not yet purged we can call GetDeletedCertificates
You will need the certificate content in PEM format to perform this operation. One sample is provided in certificate-ImportCertificate sample.
Once the import options are setup we can call Import certificate and get back the newly imported certificate.
You will need the certificate content in PKCS format to perform this operation. One sample is provided in certificate-ImportCertificate sample.
Once the import options are setup we can call Import certificate and get back the newly imported certificate
When you interact with the Azure Key Vault Secrets client library using the C++ SDK, errors returned by the service correspond to the same HTTP status codes returned for requests.
For example, if you try to retrieve a key that doesn't exist in your Azure Key Vault, a 404
error is returned, indicating "Not Found".
You will notice that additional information is logged, like the client request ID of the operation.
Several Azure Key Vault secrets client library samples are available to you in this GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Azure Key Vault:
For details on contributing to this repository, see the contributing guide.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit the Contributor License Agreement.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Many people all over the world have helped make this project better. You'll want to check out:
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secur.nosp@m.e@mi.nosp@m.croso.nosp@m.ft.c.nosp@m.om. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.