[FLINK-37504] Handle TLS Certificate Renewal - #27034
Conversation
4e21d4b to
ba980e3
Compare
61f9501 to
cc24032
Compare
c69e821 to
8481eea
Compare
|
@flinkbot run azure |
b0392e4 to
c6d586a
Compare
c6d586a to
32840cf
Compare
|
@flinkbot run azure |
| public static ServerSocketFactory createSSLServerSocketFactory(Configuration config) | ||
| throws Exception { | ||
| SSLContext sslContext = createInternalSSLContext(config, false); | ||
| SSLContext sslContext = createInternalSSLContext(config, false, false); |
There was a problem hiding this comment.
I'm not really familiar with Flink code, but can you explain why the server socket wouldn't need to watch for cert reload? I think that would be worth a comment as well.
There was a problem hiding this comment.
thanks for the comment, it is really could be confusing. Added a comment to make it a bit more explicit.
TL;DR; BlobServer uses the plain socket, there is not built-in API in java to reload the certificates, so we went with solution to simply recreate the server socket.
My understanding: It could result in temporary unavailability of the Blob Server, but with client retries practically it should lead to the slight increase of the Job deployment time for clusters which relies on the SSL reload mechanism.
ab0044f to
eb1766f
Compare
eb1766f to
248569b
Compare
|
@flinkbot run azure |
0ccdae5 to
294bdc4
Compare
There was a problem hiding this comment.
Thank you for this change, I've left some minor comments, otherwise all looks good.
The endpoint verification change looks good to me: internal SSL connections don't have endpoint verification and it's only enabled on the client side. Thank you for rebasing!
| * <p>Implementations monitor directories for file modifications and invoke registered {@link | ||
| * LocalFSWatchServiceListener} callbacks when changes occur. | ||
| */ | ||
| public interface LocalFSDirectoryWatcher { |
There was a problem hiding this comment.
I think this could be annotated as @Internal
| * } | ||
| * }</pre> | ||
| */ | ||
| public interface LocalFSWatchServiceListener { |
There was a problem hiding this comment.
This could also be annotated as @Internal
| .ciphers(ciphers) | ||
| .clientAuth(clientAuth)); | ||
| Path[] pathsToWatch = new Path[certificatePaths.size()]; | ||
| certificatePaths.toArray(pathsToWatch); |
There was a problem hiding this comment.
I think in any of the modern JVMs, it's unnecessary and slower to use pre-sized arrays, so it's safe to get rid of the unnecessary line:
certificatePaths.toArray(Path[]::new);
or
certificatePaths.toArray(new Path[0]);
| import java.nio.file.attribute.FileTime; | ||
| import java.util.Optional; | ||
|
|
||
| import static org.junit.Assert.assertTrue; |
There was a problem hiding this comment.
Please try to use JUnit 5 assertions:
import org.junit.jupiter.api.Test;
...
import static org.assertj.core.api.Assertions.assertThat;
...
assertThat(maybeCertDate)
.as("No certificates on rpc port should be accessible when SSL is disabled: " + maybeCertDate)
.isEmpty();
|
|
||
| import org.apache.flink.tests.util.flink.ClusterController; | ||
|
|
||
| import org.junit.Test; |
There was a problem hiding this comment.
Please try to use JUnit 5 here too
|
|
||
| import org.apache.flink.tests.util.flink.ClusterController; | ||
|
|
||
| import org.junit.Test; |
There was a problem hiding this comment.
Please try to use JUnit 5 here too
| import java.time.Duration; | ||
| import java.util.Optional; | ||
|
|
||
| import static org.junit.Assert.assertEquals; |
There was a problem hiding this comment.
Please try to use JUnit 5 here too
|
@mateczagany thanks a lot for review and feedback |
4d48691 to
acd53ce
Compare
2bb6343 to
b5fc855
Compare
* Unit test LocalFSWatchSingleton/SSLContextLoader * Test BlobStoreSsl to ensure certificates are reloaded
* test Blob server certificate exposure and reload in case of different ssl configs * check files are not read after certificate reload when reload/ssl is disabled
* bump e2e test module version * Fix formatting after rebase
* Remove flacky test, which is already covered by e2e * Increase e2e retries to reduce flackiness (cluster didn't start in time) * Run 20 times locally, all are green
* added for ip v4/v6 * locally test is stable with > 30 consecutive runs
b5fc855 to
01c4139
Compare
https://issues.apache.org/jira/browse/FLINK-37504
What is the purpose of the change
Implementation of the TLS Renewal for SSL.
Adds functionality to be notified if SSL keys were changed on the Flink container. Different networking mechanisms triggers the reload of new ssl keystore/truststore.
Covers the functionality with appropriate Unit Tests and Integration Tests.
More details are in design doc: https://cwiki.apache.org/confluence/display/FLINK/FLIP-523%3A+Handle+TLS+Certificate+Renewal
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation