rebind method
Rebinds the listener with a freshly built SecurityContext (used when a
certificate is renewed) without dropping live connections: a fresh
shared listener is bound on the same port with the new certificate, then
the old listener is drained gracefully (force: false) so in-flight
connections finish on the old certificate while new ones use the renewed
one.
Implementation
Future<void> rebind() async {
if (_server == null || _onRequest == null) return;
final port = _server!.port;
final oldServer = _server;
final oldSni = _sniServer;
_server = null;
_sniServer = null;
await _bindOn(port);
if (oldServer != null) unawaited(oldServer.close(force: false));
if (oldSni != null) unawaited(oldSni.close());
}