[ 
https://issues.apache.org/jira/browse/IGNITE-29212?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Anton Vinogradov updated IGNITE-29212:
--------------------------------------
    Description: 
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 hourly hot 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.
* *Hot reload covers HTTPS without settings.* The hourly 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. A certificate becomes due before it expires by a third of 
its lifetime, but by no more than 7 days. Ignite factories use the same rule 
and have no hot reload settings either. A fixed 7 days does not work for 
certificates valid for less than 7 days: they are due right after loading, so 
the node would reload them and log a failure every hour. The check still runs 
every hour. A factory that becomes due before the next hourly check is also 
checked when it becomes due, so certificates valid for a few hours are reloaded 
on time.
* *Do not switch to keys that fail to load.* This applies to both the command 
and hot 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 hot reload date stays as well, so the next hourly 
check tries again.
* *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. Hot reload logs its attempts for {{HTTP 
REST}} and counts them in the {{ssl}} metrics, as for other transports.
* *Peers must trust the replacement first.* Hot reload is always on, so a node 
loads a replaced key store by itself within an hour 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. 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.

  was:
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 hourly hot 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.
* *Hot reload covers HTTPS without settings.* The hourly 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. A certificate becomes due before it expires by a third of 
its lifetime, but by no more than 7 days. Ignite factories use the same rule 
and have no hot reload settings either. A fixed 7 days does not work for 
certificates valid for less than 7 days: they are due right after loading, so 
the node would reload them and log a failure every hour.
* *Do not switch to keys that fail to load.* This applies to both the command 
and hot 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 hot reload date stays as well, so the next hourly 
check tries again.
* *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. Hot reload logs its attempts for {{HTTP 
REST}} and counts them in the {{ssl}} metrics, as for other transports.
* *Peers must trust the replacement first.* Hot reload is always on, so a node 
loads a replaced key store by itself within an hour 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. 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.


> 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: 2.5h
>  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 hourly hot 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.
> * *Hot reload covers HTTPS without settings.* The hourly 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. A certificate becomes due before it expires by a 
> third of its lifetime, but by no more than 7 days. Ignite factories use the 
> same rule and have no hot reload settings either. A fixed 7 days does not 
> work for certificates valid for less than 7 days: they are due right after 
> loading, so the node would reload them and log a failure every hour. The 
> check still runs every hour. A factory that becomes due before the next 
> hourly check is also checked when it becomes due, so certificates valid for a 
> few hours are reloaded on time.
> * *Do not switch to keys that fail to load.* This applies to both the command 
> and hot 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 hot reload date stays as well, so the 
> next hourly check tries again.
> * *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. Hot reload logs its attempts for {{HTTP 
> REST}} and counts them in the {{ssl}} metrics, as for other transports.
> * *Peers must trust the replacement first.* Hot reload is always on, so a 
> node loads a replaced key store by itself within an hour 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. 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.



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

Reply via email to