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

azurerm_front_door - Add minimum_tls_version property #5539

Merged
merged 10 commits into from
Jan 31, 2020

Conversation

sean-nixon
Copy link
Contributor

Fixes #5538

The latest version of the Front Door API requires a minimumTlsVersion property set in the request to enable custom domain HTTPS. This PR adds support for this property with a default of "1.0" to preserved backwards compatibility. Since September 2019, Azure is making TLS 1.2 the default minimum. Once version 2.0 is released, I think the default should be updated to 1.2 to align with Azure's defaults. I've included a TODO comment and note in the upgrade guide to mark this.

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sean-nixon thanks so much for this PR and adding the minimum TLS version attribute. This LGTM! 🚀 I have also added your TODO task to my tracking issue #4627 to update the TLS post 2.0 release.

@WodansSon
Copy link
Collaborator

WodansSon commented Jan 29, 2020

@sean-nixon I noticed that if you set the TLS to 1.0 then attempt to change it to TLS 1.2, the apply executes but the TLS does not get updated to 1.2 which ends up in a constant plan loop of always wanting to change the TLS. Do you think we should add a check to see if the certificate has already been deployed and then expose and error stating something like you need to revoke the 1.0 cert before you can issue a 1.2 cert?

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sean-nixon this is almost ready to go, looking at this closer and comparing it to the current portal experience don't you think it would make more sense if this was a computed attribute and always send 1.0, since the portal does not allow you to select the version of the TLS to use? Then once 2.0 is released we can change it to always send TLS 1.2? Thanks again for your contribution. 🚀

@sean-nixon
Copy link
Contributor Author

@WodansSon Thanks for catching that issue with updates. I agree it might make sense to make the value computed given the Azure Portal behavior of completely hiding this. However, I would prefer not to always send 1.0. TLS 1.0 is no longer PCI compliant and a lot of organizations have policies to always disabling TLS 1.0, so it's not really an option for me personally.

What would you think of instead using the minimum TLS version config if it exists? If it doesn't exist already, we can then safely default to TLS 1.2 which would match the behavior in the Azure Portal.

Alternatively, I'm seeing if I can update the code to properly update the min TLS version. I think it may be possible (currently testing this), but the downside is it's essentially a complete redeployment of custom HTTPS certificates so it takes a long time. My test is still running after almost 2 hours, so I'm not sure if it will eventually error out.

@WodansSon
Copy link
Collaborator

WodansSon commented Jan 29, 2020

@sean-nixon yep, that totally makes sense... If the value is already set in azure keep sending whatever value that was previously set, be it 1.0 or 1.2, and if it is not yet defined always send 1.2. I agree that It is kind of painful that it can take up to 8 hours to completely revoke the cert once it has been deployed, but on the bright side with the new version of the API it now takes only about 10 minutes to deploy a Front Door managed cert, where in the old API it could take up to 20 hours. 😄

@timja
Copy link
Contributor

timja commented Jan 29, 2020

Have you tested this and TLS 1.2 works with front door? I implemented this locally but when I scanned it with ssllabs it still said it was using 1.0 but possibly I was doing something wrong

@timja
Copy link
Contributor

timja commented Jan 29, 2020

(Even if it doesn’t work much better to fix creation of new endpoints, unfortunately when I was testing in the upgrade I must’ve just been updating them)

@sean-nixon
Copy link
Contributor Author

@timja I created two frontends, one with 1.2 and one with 1.0 and ran Qualys checks on both of them. It does seem like 1.0 is technically supported even if you select 1.2, but only with clients that don't support SNI. There's a marked difference between the two reports:

TLS 1.2 Frontend:
image

TLS 1.0 Frontend:
image

@timja
Copy link
Contributor

timja commented Jan 29, 2020

Hmm okay I didn't notice this when I was testing, otherwise I would have submitted it earlier, bit unexpected though

Sean Nixon added 2 commits January 29, 2020 14:16
This updates the behavior to better fit with the Portal experience.
Existing frontends will continue to use TLS 1.0 while new frontends
will use TLS 1.2 as the minimum
@ghost ghost added size/S and removed size/XS labels Jan 29, 2020
@sean-nixon
Copy link
Contributor Author

@WodansSon I took a stab at making the attribute computed. I also removed the customHttpsConfiguration from the main Create/Update request. It doesn't actually affect the resource unless specifically sending an enableHttps request using the frontend client, and it wouldn't be possible to send a sane default for minimum_tls_version without separating out the Create and Update functions which seemed excessive.

Sean Nixon and others added 2 commits January 29, 2020 14:29
That attribute is now calculated so it should not be set by the user
@ghost ghost added size/L and removed size/S labels Jan 29, 2020
@WodansSon
Copy link
Collaborator

@sean-nixon Agreed. Hope you don't mind, but I added a test to validate the functionality and pushed it to your branch. If the test passes I am going to merge this code and get it in for the v1.43 release of the provider. Thanks for your help, this is great! 🚀

@sean-nixon
Copy link
Contributor Author

@WodansSon I definitely don't mind. I hadn't added one because of the external dependencies. What are the typical practices around acceptance tests that have external dependencies that need to be set up before they can pass? For example, in this case a custom domain and CNAME record for validation would need to be created and the frontend name updated before the tests could pass.

@WodansSon
Copy link
Collaborator

@sean-nixon those are more difficult, and the need to continually test it is made on a case by case basis. However, here we can work around that by using the FrontDoor managed Custom HTTPS cert provided by Microsoft, so as to not add any external dependencies. A truly custom HTTPS cert would be very difficult to code, so this way we can at least verify that the settings get set. 😃

@sean-nixon
Copy link
Contributor Author

Oh, I see what you did now. I misread your configuration. Does this actually succeed for you locally? I didn't think the default *.azurefd.net domain can have custom HTTPS settings applied to it. The default domain has HTTPS enabled by default by Azure. I believe I was getting errors for this a while back when trying to enable HTTPS using a provisioner and the Azure CLI.

@WodansSon
Copy link
Collaborator

Yep, it works just fine for me... they may have changed something in the new API that allows this.

@WodansSon
Copy link
Collaborator

image

@WodansSon WodansSon dismissed their stale review January 30, 2020 03:16

Code has been updated.

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@WodansSon WodansSon merged commit c7ca773 into hashicorp:master Jan 31, 2020
WodansSon added a commit that referenced this pull request Jan 31, 2020
@ghost
Copy link

ghost commented Feb 4, 2020

This has been released in version 1.43.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 1.43.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azurerm_frontdoor HTTPS provisioning request fails
3 participants