An open API service indexing awesome lists of open source software.

https://github.com/itk-dev/azurekeyvaultphp


https://github.com/itk-dev/azurekeyvaultphp

Last synced: 5 months ago
JSON representation

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
```