Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Credential objects missing CustomKeyIdentifier property, causes issues #6219

Closed
nonik0 opened this issue May 15, 2018 · 17 comments
Closed

Credential objects missing CustomKeyIdentifier property, causes issues #6219

nonik0 opened this issue May 15, 2018 · 17 comments
Assignees
Labels
Resource Authorization AzRole* in Az.Resources Service Attention This issue is responsible by Azure service team.

Comments

@nonik0
Copy link

nonik0 commented May 15, 2018

Hi,

I've determined that the PSADPasswordCredential and PSADKeyCredential objects defined in the object data model are missing the "CustomKeyIdentifier" property. This issue will typically not be seen if creating the objects and credentials exclusively through Azure PowerShell as the CustomKeyIdentifer property will never be populated. However, this missing property can cause issues when managing credentials on an application or service principal where one of the existing credentials in the object has a non-null value for this property. The typical error message looks like:
New-AzureRmADAppCredential : Update to existing credential with KeyId 'xxx' is not allowed.

Repro Steps:

  1. Create an application and add a credential via Azure Portal (credentials created via portal will have the CustomKeyIdentifer populated by default)
  2. Try to add a new credential of the same type to the application using Azure PowerShell
@cormacpayne cormacpayne self-assigned this May 16, 2018
@cormacpayne cormacpayne added this to the 2018-06-01 milestone May 16, 2018
@cormacpayne
Copy link
Member

@darshanhs90 Hey Haridarshan, would you happen to know why the above scenario is disallowed? I am able to reproduce the above exception, but am unsure why the server would return a BadRequest.

@cormacpayne
Copy link
Member

@darshanhs90 gentle ping

@darshanhs90
Copy link
Contributor

@markcowl markcowl modified the milestones: 2018-06-01, 2018-06-15 Jun 7, 2018
@cormacpayne cormacpayne modified the milestones: 2018-06-29, 2018-07-13 Jul 2, 2018
@cormacpayne
Copy link
Member

cormacpayne commented Jul 3, 2018

@RBACAsk ping on the question above 😀

@cormacpayne
Copy link
Member

Another repro of this issue can be found here: #6784

@markcowl markcowl removed this from the 2018-07-27 milestone Jul 27, 2018
@tonybendis
Copy link

Remove-AzureRmADAppCredential throws the same error when trying to remove key credential from an app that has multiple credentials.
I've added the credentials using New-AzureADApplicationKeyCredential, since New-AzureRmADAppCredential breaks when adding the 2nd credential (this bug).

@y325A
Copy link

y325A commented Aug 6, 2018

Does anyone have any workarounds other than the AzureAD module or a fix estimate? This has disappointingly broken my automated certificate renewal script.

@KamilTomczakSii
Copy link

I see no Chance to deploy dynamics365 on-prem without this step?
We tried with

New-AzureRmADSpCredential -ObjectId CertValue -EndDate "04.09.2019 10:24:08" -StartDate "04.09.2018 10:04:08" and the same result:
Update to existing credential with KeyId is not allowed.

@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Sep 26, 2018
@alex-moffitt
Copy link

@y325A Did you ever find a work around? I am in the same boat as you.

@darshanhs90
Copy link
Contributor

@alex-moffitt The newer powershell release should have the fix for this issue.Since @grlin fixed the issue some time back

@alex-moffitt
Copy link

@darshanhs90 or @grlin I might be doing it wrong then. I am on 6.13.1
When I do the following I get the not allowed error.

$cert = Get-AzureKeyVaultSecret -VaultName 'AAA' -Name 'BBB'

New-AzureRmADAppCredential -ApplicationId XXXX -CertValue $cert.SecretValueText

@grlin
Copy link
Contributor

grlin commented Jan 4, 2019

@alex-moffitt The fix is in the new Az 1.0 release.

@Vivihung
Copy link

@grlin For AzureRM PowerShell users, which module/library should we update to get the fix?
I'm still blocked by this issue. when calling New-AzureRmADAppCredential

@grlin
Copy link
Contributor

grlin commented Feb 26, 2019

Any version of Az after 1.0 should include the fix. AzureRM is no longer being updated.

@Vivihung
Copy link

@grlin Thanks. I didn't realize Az is actually a package.
Looks like this one:
https://www.powershellgallery.com/packages/Az/1.4.0

@masisley
Copy link

masisley commented Mar 5, 2019

@grlin I'm attempting to use this new api, but I'm failing with a new error. It appears that we fail to retrieve the application from graph and receive a 404. I can open a new issue if you'd like:

PS C:\Users\masisley> Get-AzureADServicePrincipal -ObjectId 31e7eee0-2015-490c-9581-776b4eca9c36

ObjectId                             AppId                                DisplayName
31e7eee0-2015-490c-9581-776b4eca9c36 00000003-0000-0ff1-ce00-000000000000 Office 365 SharePoint Online

PS C:\Users\masisley> New-AzureADApplicationKeyCredential -ObjectId '31e7eee0-2015-490c-9581-776b4eca9c36' -CustomKeyIdentifier ([System.Convert]::ToBase64String($cert.GetCertHash())) -Type AsymmetricX509Cert -Usage Verify -Value ([System.Convert]::ToBase64String($cert.GetRawCertData())) -StartDate $cert.NotBefore -EndDate $cert.NotAfter
New-AzureADApplicationKeyCredential : Error occurred while executing GetApplication
Code: Request_ResourceNotFound
Message: Resource '31e7eee0-2015-490c-9581-776b4eca9c36' does not exist or one of its queried reference-property
objects are not present.
RequestId: fe385086-1a3b-44f2-84b6-59acd279f926
DateTimeStamp: Tue, 05 Mar 2019 22:58:23 GMT
HttpStatusCode: NotFound
HttpStatusDescription: Not Found
HttpResponseStatus: Completed
At line:1 char:1
+ New-AzureADApplicationKeyCredential -ObjectId '31e7eee0-2015-490c-958 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureADApplicationKeyCredential], ApiException
    + FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD.Graph.PowerShell.Cus
   tom.NewAzureADApplicationKeyCredential

@grlin
Copy link
Contributor

grlin commented Mar 5, 2019

Hi @masisley I think this is a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resource Authorization AzRole* in Az.Resources Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests