Skip to content

graph: service principal's credential configured by CLI is displayed as "unknown" in portal #6299

@weinong

Description

@weinong

Environment summary

Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) / CLI version (az --version) / OS version / Shell Type (e.g. bash, cmd.exe, Bash on Windows)

2.0.31 on Azure Cloud Shell

Problem

I have a managed certificate in Keyvault. When I do az ad sp credential reset --name ${SP_ID} --append --keyvault ${KEYVAULT_NAME} --cert ${CERT_NAME}, it ran through just fine. However, when I went to the Azure Portal, the new cert has unknown thumbprint and the expiration date doesn't match the cert's. In fact, I believe the cert is not added properly because I cannot use it.

Likewise, it doesn't work with downloaded certificate..

az keyvault certificate download --vault-name ${KEYVAULT_NAME} -n ${CERT_NAME} -f ${CERT_NAME}.crt -e DER
az ad sp credential reset --name ${SP_ID} --append --cert @${CERT_NAME}.crt

'str' object has no attribute 'digest'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 197, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 347, in execute
    six.reraise(*sys.exc_info())
  File "/opt/az/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 319, in execute
    result = cmd(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 180, in __call__
    return super(AzCliCommand, self).__call__(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/knack/commands.py", line 109, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 420, in default_command_handler
    result = op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/role/custom.py", line 1176, in reset_service_principal_credential
    password, keyvault)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/role/custom.py", line 836, in _process_service_principal_creds
    logger.debug("normalizing x509 certificate with fingerprint %s", cert.digest("sha1"))
AttributeError: 'str' object has no attribute 'digest'

Finally, I had to manually download the .CER from the portal and upload to the AAD manually which works

Metadata

Metadata

Assignees

No one assigned

    Labels

    Graph-cliquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions