-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should we add a new api, "tls.Server.prototype.removeContexts(servername)" and "tls.Server.prototype.replaceContext(servername,context)" ? #34451
Comments
The problem is that it's really difficult to know when it's safe to remove a context. Removing it when it's still in use results in segfaults and even when it's gone from node's internal bookkeeping, all kinds of reference counting inside openssl can still keep it alive. |
I think the operation of "removeContexts" will not affect existing connections, but will only affect new connections in the future. |
"tls.Server.prototype.removeContexts(servername)" should be the reverse operation of "tls.Server.prototype.addContext(servername,context)" |
"tls.Server.prototype.replaceContext(servername,context)" Its role should be the operation of "tls.Server.prototype.removeContexts(servername)" and "tls.Server.prototype.addContext(servername,context)" |
@masx200 I think you misunderstand my previous comment.
The issue is that removing a Establishing when it's safe to release those resources is hard but you have to fix that first before you can fix this:
|
This is somewhat edge case, but seems like allowing However, It's possible to clear server's certificates even now using: IMO There is no point to keep useless contexts in the If one is concerned about memory and constant certificate changes, should use Result of my quick testing: repeated 50 times: 10 certs loaded/replaced + 10 requests. After last series: // SNICallback w/ own array
rss: 37 257 216 (+8 773 632)
heapTotal: 9 986 048 (+3 416 064)
heapUsed: 8 805 720 (+3 653 072)
external: 1 499 930 (+535 949)
arrayBuffers: 509 062 (+491 452)
// addContext
rss: 48 406 528 (+19 922 944)
heapTotal: 10 248 192 (+3 678 208)
heapUsed: 8 983 832 (+3 850 184)
external: 1 483 498 (+519 517)
arrayBuffers: 492 630 (+475 020)
// addContext + clearing server._contexts
rss: 44 023 808 (+15 486 976)
heapTotal: 10 248 192 (+3 678 208)
heapUsed: 8 748 112 (+3 595 424)
external: 1 443 396 (+479 415)
arrayBuffers: 451 658 (+434 048) |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
Is your feature request related to a problem? Please describe.
Please describe the problem you are trying to solve.
#34110
#34444
After adding the context with "tls.Server.prototype.addContext", the context corresponding to the specified servername cannot be deleted. Should we add a new api, "tls.Server.prototype.removeContexts(servername)"?
This is useful on HTTPS servers that need to replace ssl/tls certificates frequently, such as using "let's encrypt". When the certificate needs to be replaced, you don't want to restart the HTTPS server, you just need to replace the certificate and key.
If multiple secure contexts are added to the same domain name
, the last one added should take effect,
With frequent ssl/tls certificate updates, addContext is called constantly. If the old context is not deleted, the old context will take up more and more memory space, and they are useless. Eventually lead to memory leaks or even memory overflow.
Describe the solution you'd like
Please describe the desired behavior.
add a new api, "tls.Server.prototype.removeContexts(servername)"
the all contexts corresponding to the specified servername should be deleted.
Should we add a new api, "tls.Server.prototype.removeContexts(servername)" and "tls.Server.prototype.replaceContext(servername,context)" ?
"tls.Server.prototype.replaceContext(servername,context)" Its role should be the operation of "tls.Server.prototype.removeContexts(servername)" and "tls.Server.prototype.addContext(servername,context)"
Describe alternatives you've considered
Please describe alternative solutions or features you have considered.
The text was updated successfully, but these errors were encountered: