[ 
https://issues.apache.org/jira/browse/IGNITE-29212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18151729#comment-18151729
 ] 

Anton Vinogradov commented on IGNITE-29212:
-------------------------------------------

(/) *No blockers* — [Ignite PR 
Checker|https://ignite-pr-checker.is-a.dev/ignite?pr=13874] verdict for PR 13874

_RunAll [9527049|https://ci2.ignite.apache.org/build/9527049] · 
[3424e40|https://github.com/apache/ignite/pull/13874/commits/3424e40862195c11417236c6ba0f62efa5d849d2]
 · 
[glossary|https://github.com/anton-vinogradov/ignite-pr-checker/blob/main/docs/features.md#verdict-glossary]_

♻️ Settled after 1 auto re-run wave: #1 — 4 suites that failed mid-run.

> Reload HTTP REST certificates from the Jetty configuration
> ----------------------------------------------------------
>
>                 Key: IGNITE-29212
>                 URL: https://issues.apache.org/jira/browse/IGNITE-29212
>             Project: Ignite
>          Issue Type: Sub-task
>            Reporter: Anton Vinogradov
>            Assignee: Anton Vinogradov
>            Priority: Major
>              Labels: ise
>          Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> h3. Goal
> Let operators reload the keys and trusted certificates that Jetty uses for 
> Ignite’s HTTP REST endpoint. An operator can update the configured source and 
> run {{control.sh --ssl reload}} without restarting the node. Ignite also 
> reloads them automatically before the certificates expire, as it does for its 
> other TLS transports.
> h3. Design decisions and constraints
> * *Keep the existing Jetty configuration.* Use the TLS factory already 
> serving HTTPS, with its settings from {{jetty.xml}}. This applies to both 
> standard and custom factories. Operators should not have to configure HTTPS a 
> second time in Ignite.
> * *Let the factory load its keys.* The command and the automatic reload check 
> ask the factory to reload, once per reload. The factory reads its source 
> itself. A source can deliver new keys directly without the factory having to 
> fetch them again.
> * *Automatic reload covers HTTPS without settings.* The automatic reload 
> check from IGNITE-29211 also checks the Jetty factory. It takes the date from 
> the certificates that new connections use, including replacements that the 
> factory installed by itself. Automatic reload becomes due a lead time before 
> the earliest certificate expiry in the private key chains. Both settings stay 
> on each Ignite SSL factory: {{setAutoReloadEnabled(boolean)}}, enabled by 
> default, and {{setAutoReloadBeforeExpiryMs(long)}}, 7 days by default. The 
> names say "auto reload" rather than "hot reload": the reload command also 
> reloads without a restart, while these settings cover only the automatic 
> reload. If the source of one factory causes problems, an operator can turn 
> automatic reload off for that factory, which stops it for every transport 
> that uses this factory, and the other factories keep it. The reload command 
> still reloads the factory. An operator can also shorten the lead time for 
> short-lived certificates. The HTTP REST endpoint takes both settings from its 
> own Jetty factory, so an operator can turn automatic reload off for HTTPS and 
> keep it for binary REST. A Jetty factory keeps the defaults unless it 
> implements the new public interface 
> {{org.apache.ignite.ssl.jetty.AutoReloadJettySslFactory}} with 
> {{isAutoReloadEnabled()}} and {{getAutoReloadBeforeExpiryMs()}}. To change 
> them, the operator uses a subclass of {{SslContextFactory.Server}} that 
> implements the interface and has setters for both properties, and sets them 
> in {{jetty.xml}}. Existing {{jetty.xml}} files work unchanged. Each factory 
> is checked when it becomes due, but no later than an hour after its previous 
> check, so a lead time shorter than an hour is not missed. The check reads the 
> date once and decides from it both whether to reload now and when to check 
> next. The first check reads the date at start in the background, so a factory 
> that fails to report it does not stop the node start: the check reports the 
> failure and retries an hour later. If the date cannot be read after a manual 
> reload, the command still succeeds, and the next check comes an hour later.
> * *Do not switch to keys that fail to load.* This applies to both the command 
> and automatic reload. As with Ignite factories, a failed reload leaves the 
> last working keys and trust settings in use, even while the source remains 
> unreadable. This includes the certificate that the factory selects by SNI 
> host name, and keys that a source set on the factory directly. New 
> connections never get a factory without keys: during a reload they wait and 
> then get either the replacement or the previous keys. Established connections 
> stay open. If an automatic update installed certificate B, clients must still 
> see B after a failed manual reload. The automatic reload date stays as well, 
> so the check tries again an hour later. A failed reload by Jetty's own 
> {{KeyStoreScanner}} can leave the factory without keys. Such a factory is due 
> for automatic reload right away, and a reload has nothing to restore: it 
> loads the configured sources. Once the stores are corrected, the reload 
> command or the next automatic reload check brings HTTPS back.
> * *Report what happened on each node.* The command reports {{HTTP REST}} as 
> reloaded once new connections can use the replacement. On failure it reports 
> the node and the cause, even if HTTPS recovered. The operator can fix the 
> source and retry the same command. Automatic reload logs its attempts for 
> {{HTTP REST}} and counts them in the {{ssl}} metrics, as for other 
> transports. It logs the automatic reload date whenever a check or a reload 
> finds a new one, including one that the factory installed by itself.
> * *Peers must trust the replacement first.* Automatic reload is enabled by 
> default, so a node loads a replaced key store on its next check once the old 
> certificate is due. If clients or other nodes do not trust the new 
> certificate yet, their new connections fail. The documentation presents the 
> trust-first order as the general rule for replacing certificates.
> h3. Implementation idea
> On each node serving HTTPS, obtain the TLS factory from the Jetty connector 
> and call {{SslContextFactory.reload(...)}} on that instance. Look for it 
> among all components of the connector, not only its top-level connection 
> factories: a {{DetectorConnectionFactory}}, which accepts HTTP and HTTPS on 
> one port, holds the TLS factory inside. Jetty’s factory clears its active TLS 
> state before loading the replacement, and its public API cannot build a 
> replacement next to the active one. New connections take the TLS state under 
> the factory’s lock. So do the whole reload under that lock: if loading fails, 
> give the factory back its last working {{SSLContext}} together with its key 
> and trust stores before releasing the lock. Jetty 12.1.15 selects the 
> certificate for an SNI host from the key store that the factory holds, so SNI 
> selection keeps working. Then set back the context and stores that 
> {{jetty.xml}} configured, read before Jetty starts, so that the next reload 
> uses the configured sources again. Jetty’s getters return the loaded state 
> once the factory has started, so Ignite cannot read a context or store that 
> code sets on the running factory. After a failed reload, the next reload uses 
> the {{jetty.xml}} sources instead of such a setting. The documentation asks 
> users to keep the stores in the sources that the factory loads: store paths 
> in {{jetty.xml}}, or the {{loadKeyStore(Resource)}} and 
> {{loadTrustStore(Resource)}} methods of a custom subclass.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to