https://github.com/itk-dev/azurekeyvaultphp
https://github.com/itk-dev/azurekeyvaultphp
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/itk-dev/azurekeyvaultphp
- Owner: itk-dev
- Created: 2020-08-12T08:10:19.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2024-09-25T09:25:02.000Z (over 1 year ago)
- Last Synced: 2024-12-20T15:41:51.091Z (over 1 year ago)
- Language: PHP
- Size: 50.8 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Azure Key Vault
This is a php library to access certificates and secrets stored in Azure key vault through their rest API.
See https://docs.microsoft.com/en-gb/azure/key-vault/general/
# Installation
Add the github repository to your composer.json.
```json
"repositories": {
"itk-dev/azure-key-vault-php": {
"type": "vcs",
"url": "https://github.com/itk-dev/AzureKeyVaultPhp"
}
},
```
Use composer to install the library.
```sh
composer require itk-dev/azure-key-vault-php": "dev-master"
```
# Usage
```php
getToken(
'xxxx',
'yyyy',
'zzzz'
);
// Certificates
// This requires a PSR-18 compatible http client and a PSR-17 compatible request factory.
// Get vault with the name 'testVault' using the access token.
$vault = new VaultCertificate($httpClient, $requestFactory, 'testVault', $token->getAccessToken());
$cert = $vault->getCertificate('TestCert', '8cb726a7bd52460a96a5496672562df0');
echo $cert->getCert();
// Secrets
// This requires a PSR-18 compatible http client and a PSR-17 compatible request factory.
// Get vault with the name 'testVault' using the access token.
$vault = new VaultSecret($httpClient, $requestFactory, 'testVault', $token->getAccessToken());
$secret = $vault->getSecret('TestCert', '8cb726a7bd52460a96a5496672562df0');
echo $secret->getValue();
```
# Storing certificates in the vault
You may have to rename your `.p12` file to `.pfx` before being able to upload to the Azure Key Vault.
## Removing passphrase from PKCS12 certificates
If you don't want to have a passphrase on the certificate stored in the Azure Key Vault,
you can use the following command to remove the passphrase:
```shell
openssl pkcs12 -in certificate.p12 -nodes | openssl pkcs12 -export -out certificate.passwordless.pfx
```