You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tls.createSecureContext() method creates a SecureContext object. It is usable as an argument to several tls APIs, such as server.addContext(), but has no public methods. The tls.Server constructor and the tls.createServer() method do not support the secureContext option.
So according to the documentation, server.addContext() should take a SecureContext object as an argument. However, according to the documention of server.addContext(), the only valid argument for options is SecureContextOptions, but not the SecureContext object itself.
I have tried passing a SecureContext object to server.addContext(). While it did not throw any errors, it did not configure the secure context properly.
It would really be nice if server.addContext() would take a SecureContext object. Ideally, you should fix the code and update the documentation for server.addContext().
Pull request welcome. You can check inside addContext() if the context argument is already instanceof SecureContext and then use context.context instead of passing context to tls.createSecureContext():
Activity
bnoordhuis commentedon Apr 4, 2023
Pull request welcome. You can check inside addContext() if the context argument is already instanceof SecureContext and then use
context.contextinstead of passingcontexttotls.createSecureContext():node/lib/_tls_wrap.js
Lines 1479 to 1480 in 6fd147c
shollander commentedon Apr 4, 2023
Seems like a relatively simple change. Unfortunately, I don't have an environment where I can readily build and test node.js.
HinataKah0 commentedon Apr 6, 2023
If you want to try, you can refer to this for building Node JS locally.
tls: accept SecureContext object in server.addContext()
tls: accept SecureContext object in server.addContext()
tls: accept SecureContext object in server.addContext()
tls: accept SecureContext object in server.addContext()