[
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 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 hot 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. 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. Each factory is
checked when it becomes due, but no later than an hour after its previous
check, so certificates valid for a few hours are reloaded on time. 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.
* *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 check tries
again an hour later.
* *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. It logs
the hot 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.* 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. 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.
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 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 hot 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. 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. Each factory is
checked when it becomes due, but no later than an hour after its previous
check, so certificates valid for a few hours are reloaded on time. 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.
* *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 check tries
again an hour later. If Jetty fails to load the previous keys back as well, new
HTTPS connections fail, and the documentation tells the operator to fix the
cause and restart the node.
* *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. It logs
the hot 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.* 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. 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.
> 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 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 hot 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. 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. Each
> factory is checked when it becomes due, but no later than an hour after its
> previous check, so certificates valid for a few hours are reloaded on time.
> 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.
> * *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
> check tries again an hour later.
> * *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. It
> logs the hot 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.* 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. 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)