Azure / api-management-policy-snippets

Re-usable examples of Azure API Management policies
MIT License
341 stars 155 forks source link

Certificate REST API not working #49

Closed PratikT29 closed 4 years ago

PratikT29 commented 4 years ago

Hi, I am new to APIM and its policies, I observe that this example is using the Key Vault secret API instead of the certificate API but the Key vault secret API for certificate is deprecated and not allowing to upload certificates in secrets. I tried using certificate API "https://**mykeyvault.**vault.azure.net**/certificates/mycertificate**/?api-version=2016-10-01" but getting error while setting set-variable name="keyVaultCertBase64" . set-variable { "messages": [ { "message": "Expression evaluation failed.", "expression": "((IResponse)context.Variables[\"keyVaultCertResponse\"]).Body.As()[\"value\"].ToString()", "details": "Object reference not set to an instance of an object." }, "Expression evaluation failed. Object reference not set to an instance of an object.", "Object reference not set to an instance of an object." ] }

When I updated line 30 to, set-variable name="keyVaultCertBase64" value="@(((IResponse)context.Variables["keyVaultCertResponse"]).Body.As() it returns certificate but then "authentication-certificate body....." fails with not valid base64 string error. Any help here would be much appreciated.

Thanks, Pratik

PratikT29 commented 4 years ago

Hi When I say Key vault secret for certificate is deprecated, I was referring to below msg, image

This created confusion and I used certificate API "https://mykeyvault.vault.azure.net/**certificates**/mycertificate/?api-version=2016-10-01" which was giving me errors, reverting to secret API "https://mykeyvault.vault.azure.net/**secretes**/mycertificate/?api-version=2016-10-01" works fine. Thus closing this issue.

Thanks, Pratik