azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

issue with .cer certificate

Open djaus2 opened this issue 6 years ago • 14 comments

I have generated a ValidationCertification.cer file. I now want to upload it and verify the certificate, without going to the Azure Portal.

az iot dps certificate verify only has and example for a .pem file. Can I not use this command with the .cer file?

Nb: tried that and got:

PS C:\temp> azsphere tenant download-validation-certificate --output ValidationCertification139.cer --verificationcode CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

Saving the validation certificate to 'C:\temp\ValidationCertification139.cer'.
Saved the validation certificate to 'ValidationCertification139.cer'.

PS C:\temps> az iot dps certificate verify --dps-name $DPSName --resource-group $GroupName --name MyCertificate137 --path ValidationCertification139.cer --etag AAAAAALTXUo=

Invalid ETag supplied. If you contact a support representative please include this correlation identifier: 48ab965d-7916-46e9-9856-61745accce7a, timestamp: 2020-04-21 05:39:59Z, errorcode: IH412001.

The etag used was from the earlier az iot dps certificate create command and used in the az iot dps certificate generate-verification-code command.

{
  "etag": "AAAAAALTXUo=",
  "id": "/s

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

djaus2 avatar Apr 21 '20 05:04 djaus2

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @rkmanda, @chieftn.

ghost avatar Apr 21 '20 08:04 ghost

iot

yonzhan avatar Apr 21 '20 08:04 yonzhan

Issue was that the etag changes and has to be redetermined from a query to do the Verification. This is now part of my https://Github.com/djaus2/az-iothub-ps GitHub repo

djaus2 avatar May 20 '20 02:05 djaus2

Also found I can just use the full local path the Validation .cer file. Doesn't have to be .pem Example documentation should be adjusted for that.

djaus2 avatar May 20 '20 02:05 djaus2

Also found I can just use the full local path the Validation .cer file. Doesn't have to be .pem

If your .cer file is in PEM format, the file extension shouldn't matter (as long as the file only contains the leaf).

But I'm also having the same issue as you, and it seems to ot just affect az iot dps certificate create. I'm doing:

  1. Get the etag with:
az iot dps certificate show
  1. Get a verification code:
az iot dps certificate generate-verification-code
  1. (create and sign a certificate)

  2. Upload the verified cert, using the same etag from (1):

az iot dps certificate verify

This fails with Invalid ETag supplied

cocowalla avatar May 26 '20 12:05 cocowalla

You need to get the etag again after step 2 or 3. That what I found and it works. I have done that in my az-iothub-ps code on GitHub: https:/github.com.djaus2/az-iothub-ps I can do all of that Verification from the command line.

Unfortunately the same is not true for IoT Central Verification

From: cocowalla [email protected] Sent: Tuesday, 26 May 2020 10:52 PM To: Azure/azure-cli [email protected] Cc: David Jones (MVP) [email protected]; Author [email protected] Subject: Re: [Azure/azure-cli] issue with .cer certificate (#13098)

Also found I can just use the full local path the Validation .cer file. Doesn't have to be .pem

If your .cer file is in PEM format, the file extension shouldn't matter (as long as the file only contains the leafhttps://github.com/Azure/azure-cli/issues/11131).

But I'm also having the same issue as you, and it seems to ot just affect az iot dps certificate create. I'm doing:

  1. Get the etag with:

az iot dps certificate show

  1. Get a verification code:

az iot dps certificate generate-verification-code

  1. (create and sign a certificate)
  2. Upload the verified cert, using the same etag from (1):

az iot dps certificate verify

This fails with Invalid ETag supplied

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-cli/issues/13098#issuecomment-634004804, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC7U2EJZSEEK7AFZBASRWHTRTO3OZANCNFSM4MNAJZDA.

djaus2 avatar May 26 '20 13:05 djaus2

@Azure/azure-iot-cli-triage

yiyiguo avatar Sep 15 '20 22:09 yiyiguo

Please don't close this until it is resolved. Seems bots are closing a few of these unresolved issues saying they have been orphaned.

djaus2 avatar Sep 16 '20 04:09 djaus2

  1. (create and sign a certificate)
  2. Upload the verified cert, using the same etag from (1):
az iot dps certificate verify

This fails with Invalid ETag supplied

@cocowalla - just ran through this scenario, and @djaus2 is correct, the generate-verification-code function (and service call) returns the cert with a new etag along with the verification code. Because the verification code is stored in the properties of the backing certificate object, the etag will have changed since the initial show step, as both the verificationCode and updated time stamp have changed.

In order to work through closing this - @cocowalla and @djaus2 - are there any outstanding issues here (regarding this specific issue) in the functionality of the CLI itself? Or is the issue pertaining to missing / incomplete / incorrect documentation?

P.S - @cocowalla , I'm digging into #11131 (just reproed this with another example cert while running through this scenario) and will update you on that issue in that thread once I nail down the issue.

c-ryan-k avatar Sep 16 '20 18:09 c-ryan-k

To clarify the verification process of commands (assuming all have --dps-name {dps} -g {resource_group}):

  1. az iot dps certificate create -p "path\to\cert" -n {cert_name} - This uploads the certificate to the DPS instance, and returns {..."etag": "etag1"}
  2. [optional] az iot dps certificate show -n {cert_name} - This returns {..."etag": "etag1"}
  3. az iot dps certificate generate-verification-code -n {cert_name} --etag {etag1} - This returns {..."etag": "etag2"} and the verificationCode for signing the verification certificate
  4. Sign another certificate {cert2} using the verificationCode from step 3
  5. az iot dps certificate verify -n {cert_name} --etag {etag2} --path {path/to/cert2} - This returns {..."etag": "etag3"} and "isverified": true

c-ryan-k avatar Sep 16 '20 19:09 c-ryan-k

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Nov 18 '20 02:11 ghost

Looking at this again now.

djaus2 avatar Nov 18 '20 10:11 djaus2

@djaus2 Do you still need help with this issue? Otherwise, I would like to close it.

vilit1 avatar Dec 08 '21 21:12 vilit1

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Feb 09 '22 08:02 ghost