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

Enable-AzFrontDoorCustomDomainHttps doesnt return error / removes https settings from endpoint

Open timpoth opened this issue 6 years ago • 5 comments

We have a case where one of our certs isnt compatible with azure frontdoor and the error we get through the azure portal is:

'Failed to update the custom https configuration for the frontend host 'ENDPOINTNAME'. Error: The private key is not RSA or it is unreadable. Only RSA private key is supported for BYOC to secure a custom domain.' (we have a support case open about this)

This error is not returned when running the Enable-AzFrontDoorCustomDomainHttps cmdlet but FAR WORSE after the cmdlet is run it removes the currently configured cert from the endpoint so rather than us getting an updated cert as expected we are left with a broken config and a cert error is presented to our users.

timpoth avatar Sep 23 '20 20:09 timpoth

@timpoth, could you please provide the debug stream and environment data?

Description

Steps to reproduce


Environment data


Module versions


Debug output


Error output


erich-wang avatar Sep 24 '20 00:09 erich-wang

Steps: have end point with cert loaded upload new cert to keyvault that AFD doesnt like (lets encrypt cert exported from powershell in my case) run: Enable-AzFrontDoorCustomDomainHttps -ResourceGroupName 'RGName' -FrontDoorName 'FDName' -FrontendEndpointName 'FEName' -Vault 'valutresourceid' -secretName 'secretname' -SecretVersion 'secretversion'

AZ version 4.7.0 az.frontdoor 1.6.1

debug attached dbg.log

no error output but if you look in azure portal youll find the cert binding has been removed.

timpoth avatar Sep 24 '20 20:09 timpoth

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

ghost avatar Oct 01 '20 00:10 ghost

Service team, please help to look into this question.

dingmeng-xue avatar Oct 01 '20 00:10 dingmeng-xue

Hi @timpoth, service team has refined the certificate validation logic to reject the invalid operation earlier. Most of the validation errors (including the one you encountered) should be detected in the API call to trigger the https deployment now. Front Door service used to accept those invalid requests and fail the operation in the backend, you have to poll the operation status to get the exact failure reasons. That is why you observed the inconsistency between Azure Portal and Azure PowerShel. Azure Portal has underlyingly performed the status poll for you.

PS C:\WINDOWS\system32> Get-AzFrontDoorFrontendEndpoint -ResourceGroupName bzhanafdtest -FrontDoorName 12345-bzhan-test -Name pstest2


HostName                         : pstest2.localdev.cdn.azure.cn
SessionAffinityEnabledState      : Disabled
SessionAffinityTtlSeconds        : 0
WebApplicationFirewallPolicyLink :
Backends                         :
CustomHttpsProvisioningState     : Enabled
CustomHttpsProvisioningSubstate  : CertificateDeployed
CertificateSource                : AzureKeyVault
ProtocolType                     : ServerNameIndication
MinimumTlsVersion                : 1.2
Vault                            : /subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourceGroups/bzhanafdtest/providers/Microsoft.KeyVault/vaults/bzhanbyostest
SecretName                       : wildcard-localdev
SecretVersion                    : 9024765bbe5044c1b35df84c53429f09
CertificateType                  :
ResourceState                    : Enabled
Id                               : /subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourcegroups/bzhanafdtest/providers/Microsoft.Network/frontdoors/12345-bzhan-test/frontendendpoints/pstest2
Name                             : pstest2
Type                             : Microsoft.Network/frontdoors/frontendendpoints



PS C:\WINDOWS\system32> Enable-AzFrontDoorCustomDomainHttps -ResourceGroupName bzhanafdtest -FrontDoorName 12345-bzhan-test -FrontendEndpointName pstest2 -VaultId /subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourceGroups/bzhanafdtest/providers/Microsoft.KeyVault/vaults/bzhanbyostest -SecretName certmy -SecretVersion 721f01173f64441faa09e6ec9accdde9
Enable-AzFrontDoorCustomDomainHttps : Error response received. Error Message: '{
  "error": {
    "code": "BadRequest",
    "message": "The server (leaf) certificate isn't within the validity period."
  }
}'
At line:1 char:1
+ Enable-AzFrontDoorCustomDomainHttps -ResourceGroupName bzhanafdtest - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Enable-AzFrontDoorCustomDomainHttps], PSArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.FrontDoor.Cmdlets.EnableFrontDoorCustomDomainHttps

PS C:\WINDOWS\system32> Enable-AzFrontDoorCustomDomainHttps -ResourceGroupName bzhanafdtest -FrontDoorName 12345-bzhan-test -FrontendEndpointName pstest2 -VaultId /subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourceGroups/bzhanafdtest/providers/Microsoft.KeyVault/vaults/bzhanbyostest -SecretName selfissue -SecretVersion 39970ec8b17a4f9db23e549f1aa7f28a
Enable-AzFrontDoorCustomDomainHttps : Error response received. Error Message: '{
  "error": {
    "code": "BadRequest",
    "message": "The certificate imported from the Key Vault is a Self Signed certificate and is not permitted for Bring Your Own Certificate"
  }
}'
At line:1 char:1
+ Enable-AzFrontDoorCustomDomainHttps -ResourceGroupName bzhanafdtest - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Enable-AzFrontDoorCustomDomainHttps], PSArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.FrontDoor.Cmdlets.EnableFrontDoorCustomDomainHttps

PS C:\WINDOWS\system32> Enable-AzFrontDoorCustomDomainHttps -ResourceGroupName bzhanafdtest -FrontDoorName 12345-bzhan-test -FrontendEndpointName pstest2 -VaultId /subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourceGroups/bzhanafdtest/providers/Microsoft.KeyVault/vaults/bzhanbyostest -SecretName ecdsa -SecretVersion 50d68051bdf9489691a4da6d4fd78999
Enable-AzFrontDoorCustomDomainHttps : Error response received. Error Message: '{
  "error": {
    "code": "BadRequest",
    "message": "The private key is not RSA or it is unreadable. Only RSA private key is supported for BYOC to secure a custom domain. "
  }
}'
At line:1 char:1
+ Enable-AzFrontDoorCustomDomainHttps -ResourceGroupName bzhanafdtest - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Enable-AzFrontDoorCustomDomainHttps], PSArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.FrontDoor.Cmdlets.EnableFrontDoorCustomDomainHttps

PS C:\WINDOWS\system32> Get-AzFrontDoorFrontendEndpoint -ResourceGroupName bzhanafdtest -FrontDoorName 12345-bzhan-test -Name pstest2


HostName                         : pstest2.localdev.cdn.azure.cn
SessionAffinityEnabledState      : Disabled
SessionAffinityTtlSeconds        : 0
WebApplicationFirewallPolicyLink :
Backends                         :
CustomHttpsProvisioningState     : Enabled
CustomHttpsProvisioningSubstate  : CertificateDeployed
CertificateSource                : AzureKeyVault
ProtocolType                     : ServerNameIndication
MinimumTlsVersion                : 1.2
Vault                            : /subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourceGroups/bzhanafdtest/providers/Microsoft.KeyVault/vaults/bzhanbyostest
SecretName                       : wildcard-localdev
SecretVersion                    : 9024765bbe5044c1b35df84c53429f09
CertificateType                  :
ResourceState                    : Enabled
Id                               : /subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourcegroups/bzhanafdtest/providers/Microsoft.Network/frontdoors/12345-bzhan-test/frontendendpoints/pstest2
Name                             : pstest2
Type                             : Microsoft.Network/frontdoors/frontendendpoints

Please retry to see whether the issue is addressed.

t-bzhan avatar Feb 09 '22 04:02 t-bzhan