util: Automatically create TLS certificates#24141
Conversation
|
/cc @mjonss |
|
Getting a test failure: |
mjonss
left a comment
There was a problem hiding this comment.
I have some small suggestions.
util/misc.go
Outdated
There was a problem hiding this comment.
Should these 90 days be configurable? Or just documented that if you don't manage any TLS certificates, there will be a temporary self-signed cert created that is valid for 90 days and then you need to restart the TiDB node?
There was a problem hiding this comment.
Good question. Not sure what to do. For now I've added the validity of the cert to the logging, however zap.Duration doesn't format it in the best way possible...
We could:
- Make the certificates valid for 3 years and expect people to restart before they reach this. Should this be 1 year? 10 years?
- We could re-create the certs every 60 days or so and trigger the code behind
ALTER INSTANCE RELOAD TLS - We could put a note in the docs saying that the user has to restart every <90 days
This is related to pingcap/docs#4299
I think option 2 is probably best. What do you think?
Could/should we have a hook or so that we call when the certificates are about to expire? Then this allows integration with ACME and local certificate rotation things. But I also don't want to make this too complicated.
There was a problem hiding this comment.
Lines 1354 to 1372 in 59b99ce
There was a problem hiding this comment.
I've updated the code to have a goroutine create new certs every 30 days.
f546c24 to
3f22a54
Compare
mjonss
left a comment
There was a problem hiding this comment.
Thank you for the update, I don't see how I can reply to the discussion about certificate life time, so I'm pasting it here again :(
@mjonss mjonss 15 hours ago Member
Should these 90 days be configurable? Or just documented that if you don't manage any TLS certificates, there will be a temporary self-signed cert created that is valid for 90 days and then you need to restart the TiDB node?
@dveeden dveeden 1 hour ago Author Member
Good question. Not sure what to do. For now I've added the validity of the cert to the logging, however zap.Duration doesn't format it in the best way possible...
We could:
Make the certificates valid for 3 years and expect people to restart before they reach this. Should this be 1 year? 10 years?
We could re-create the certs every 60 days or so and trigger the code behind ALTER INSTANCE RELOAD TLS
We could put a note in the docs saying that the user has to restart every <90 days
This is related to pingcap/docs#4299
I think option 2 is probably best. What do you think?
Could/should we have a hook or so that we call when the certificates are about to expire? Then this allows integration with ACME and local certificate rotation things. But I also don't want to make this too complicated.
Mattias>
I agree with option 2. What happens when it is reloaded, will it force current connections to be disconnected or can they just continue until they disconnect?
504ae44 to
ee849f6
Compare
util/misc.go
Outdated
There was a problem hiding this comment.
Nice solution!
Should we also randomise the reloading over a day, so not all the TiDB nodes reloads at the same time, but spreads it out a bit? (Only a suggestion, patch approved)
|
@mjonss: DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
|
/lgtm |
|
I see some issues with the current state of this PR:
An OpenSSL one-liner to get the dates from the MySQL protocol. This can be used until |
|
/merge |
|
@zhouqiang-cl: DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
|
/run-check_dev_2 |
1 similar comment
|
/run-check_dev_2 |
|
@dveeden Seems this pr make CI much slower #26717 /cc @tiancaiamao |
|
After this change, some test case runs slower than before. I filter the cases that run more than 1s, master branch: and this branch: You can try this step manually to verify that: And we are preventing the CI to be slower #26575 |
|
/merge cancel |
|
@zhouqiang-cl: DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
|
/merge cancel |
|
@tiancaiamao Thanks for the info about the CI testing. The issue is that creating the certificates takes a bit of time and if we include that in many of the tests then that adds up. f7c1a269fdcbf5cf30f09a14fad5251c93723226 should fix that. This is what I get now: The list is the same as for the master branch |
If no `ssl-cert` or `ssl-key` are specified: Create a self signed cert in the temp storage and use that. This allows TLS to be used when no user created certificates are available. Especially for `tiup playground` and other simple cases this should be sufficient. Note that for `caching_sha2_password` support we will either need TLS connections or RSA keypairs. This brings us a step closer in that direction. The created certificate are valid for 90 days and new certificates are created every 30 days. See also: - "Automatic SSL and RSA File Generation" on https://dev.mysql.com/doc/refman/8.0/en/creating-ssl-rsa-files-using-mysql.html - https://docs.pingcap.com/tidb/stable/enable-tls-between-clients-and-servers - pingcap#9411 - pingcap#18084
|
/merge The CI timeout limit is changed to 5s ... |
|
This pull request has been accepted and is ready to merge. DetailsCommit hash: dc842a5 |
|
/run-check_dev_2 |
|
@dveeden: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Problem Summary:
Configuring TLS should be as easy as possible and having to use
mysql_ssl_rsa_setupfrom MySQL server should not be needed for simple setups.What is changed and how it works?
What's Changed:
If no
ssl-certorssl-keyare specified: Create a self signedcert in the temp storage and use that.
This allows TLS to be used when no user created certificates are
available.
Especially for
tiup playgroundand other simple cases this should besufficient.
Note that for
caching_sha2_passwordsupport we will either need TLSconnections or RSA keypairs. This brings us a step closer in that
direction.
Related
Check List
Tests
Run
tidb-serverwithout TLS configured and then connect with a modern MySQL client and use\sto see if TLS is used.Release note
ssl-certorssl-keyconfigured.