nizhikov commented on code in PR #13786:
URL: https://github.com/apache/ignite/pull/13786#discussion_r4583281829
##########
modules/commons/src/main/java/org/apache/ignite/ssl/SslContextFactory.java:
##########
@@ -85,6 +93,69 @@ public class SslContextFactory extends
AbstractSslContextFactory {
/** Trust managers. */
protected TrustManager[] trustMgrs;
+ /** */
+ private boolean hotReloadEnabled;
+
+ /** */
+ private transient volatile long hotReloadTime;
+
+ /** */
+ private transient long pendingHotReloadTime;
+
+ /**
+ * @return Whether automatic certificate hot reload is enabled. Defaults
to {@code false}.
+ */
+ public boolean isHotReloadEnabled() {
+ return hotReloadEnabled;
+ }
+
+ /**
+ * @param enabled Whether automatic certificate hot reload is enabled.
Changes require a node restart.
+ */
+ public void setHotReloadEnabled(boolean enabled) {
+ hotReloadEnabled = enabled;
+ }
+
+ /**
+ * The hot reload time is calculated from the certificates loaded with hot
reload enabled.
+ * The chain that expires first determines the window, which starts with
15% of its lifetime remaining.
+ * Its lifetime runs from the key certificate's {@code notBefore} to the
earliest {@code notAfter} in its chain.
+ * The window never starts after the chain expires.
+ * For chains with the same expiry, the longest lifetime is used.
+ *
+ * @return Start of the hot reload window in milliseconds since the epoch,
or {@code 0} if the current certificates
+ * were loaded with hot reload disabled or have not been loaded yet.
+ */
+ public long getHotReloadTime() {
+ return hotReloadTime;
+ }
+
+ /**
+ * Replaces the current SSL context when the hot reload window has started.
+ * Does nothing when hot reload is disabled, no hot reload date has been
loaded, or the window has not started.
+ * A failed replacement leaves the current context and hot reload time
unchanged.
+ *
+ * @throws IgniteException If the replacement cannot be loaded or accepted.
+ */
+ public void hotReload() {
+ if (!hotReloadEnabled)
+ return;
+
+ long hotReloadTime = getHotReloadTime();
+
+ if (hotReloadTime != 0 && hotReloadTime <= System.currentTimeMillis())
+ init();
+ }
+
+ /** {@inheritDoc} */
+ @Override SSLContext createSslContext() throws SSLException {
+ SSLContext ctx = super.createSslContext();
Review Comment:
Let's get rid of temporary instance variable:
```
long prevHotReloadTime = hotReloadTime;
try {
return super.createSslContext();
}
catch (Throwable ignored) {
hotReloadTime = prevHotReloadTime;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]