Azure / Azure/azure-cli

az keyvault certificate import does not accept PEM format

Open
#19,017 8 comments 0 reactions 1 assignee Claimed by @evelyn-ys View on GitHub
act-identity-squad KeyVault Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Describe the bug**
az cli command `az keyvault certificate import` doesn't accept PEM certificate as an argument for the `--file `parameter.
However, according to [official documentation](https://docs.microsoft.com/en-us/cli/azure/keyvault/certificate?view=azure-cli-latest#az-keyvault-certificate-import), the following arguments should be supported for `--file` parameter: _PKCS12 file or PEM file containing the certificate and private key_.

**To Reproduce**

- Create vault
- Try to import PEM certificate by executing the following command: `az keyvault certificate import --vault-name --name --file `
- Instead of successful certificate import, the following error raised: `PEM is in unexpected format`

The generated cert-file.pem looks like:

```
-----BEGIN CERTIFICATE-----
MIID2TCCAsGg...
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
MIIEvQIBADAN...
-----END PRIVATE KEY-----
```

Also tried (out of curiosity) to change key and cert position - which doesn't make any difference in theory (still fails).

```
-----BEGIN PRIVATE KEY-----
MIIEvQIBADAN...
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIID2TCCAsGg...
-----END CERTIFICATE-----
```

**Expected behavior**
PEM certificate successfully imported to vault

**Environment summary**

```
az --version
azure-cli 2.26.1

core 2.26.1
telemetry 1.0.6

Extensions:
managementpartner 0.1.3

Python location '/opt/azure-cli/bin/python'
Extensions directory '/home/hadrian/.azure/cliextensions'

Python (Linux) 3.9.5 (default, May 24 2021, 12:50:35)
[GCC 11.1.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.
```
This is a duplicate of https://github.com/Azure/azure-cli/issues/8099, which is closed without fixing the problem.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.