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
{{ message }}
Repository navigation
How to use fetch() from utility process with self-signed certs / custom proxy settings? #44727
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Problem Description
Context
It is possible to use net.fetch() from a utility process. As stated here in the documentation:
This method will issue requests from the default session. To send a fetch request from another session, use ses.fetch().
So using net.fetch() in a utility process basically comes down to using session.defaultSession.fetch().
Requirement
I need to use session.setCertificateVerifyProc() in order to accept self-signed certificates from a given certificate authority. However, I want that logic to be limited to the task performed by a utility process. So I would like to do the following in a utility process:
create a session that is specific to that utility process (using session.fromPartition())
call setCertificateVerifyProc() on that specific session
to then call fetch() on that specific session
Problem
session is undefined in the context of a utility process.
Proposed Solution
Make session available in the context of a utility process.
Note that this could maybe help reconcile the 2 different ways of setting proxy configuration (see below, this is error-prone).
constconfig={ proxyRules };// Set proxy settings for main process and renderer processessession.defaultSession.setProxy(config);// Set proxy settings for utility processapp.setProxy(config);
Alternatives Considered
NA
Additional Information
No response
Reacted by chulanovskyi-bs, Ugo Bechameil, Taras Dubyk, Yevhenii Moroziuk, Aleksandr Termenzhy, Dmytro Revenets, Farid Shabanov, Andrii Tkachenko, Alik, Viktoriia Kozopas and 20 more
So using net.fetch() in a utility process basically comes down to using session.defaultSession.fetch()
Actually that is not what happens today, the doc needs improvement. Requests from utility process do not use the default session, rather they use a hidden network context that is scoped to the app which is not exposed. Hence the proxy settings for this process also get applied via app.setProxy.
In the current implementation, we would need a app.setCertificateVerifyProc(). However, I don't want to go down the path of duplicating every session specific api for the app network context. It is possible to support a session for the utility process, but it has to happen at the time of creating the process similar to how we do it for webContents, something like
utilityProcess.fork(.., {
session?: Session
})
Also for design reasons, the session object cannot be accessed inside the utility process which means net.request({session: ...}) will still remain a no-op.
Actually that is not what happens today, the doc needs improvement. Requests from utility process do not use the default session, rather they use a hidden network context that is scoped to the app which is not exposed. Hence the proxy settings for this process also get applied via app.setProxy.
This is probably what explains the issue #44264...
Activity
deepak1556 commentedon Nov 19, 2024
Actually that is not what happens today, the doc needs improvement. Requests from utility process do not use the default session, rather they use a hidden network context that is scoped to the app which is not exposed. Hence the proxy settings for this process also get applied via
app.setProxy.In the current implementation, we would need a
app.setCertificateVerifyProc(). However, I don't want to go down the path of duplicating every session specific api for the app network context. It is possible to support a session for the utility process, but it has to happen at the time of creating the process similar to how we do it for webContents, something likeAlso for design reasons, the session object cannot be accessed inside the utility process which means
net.request({session: ...})will still remain a no-op.thomas-jakemeyn commentedon Nov 19, 2024
This is probably what explains the issue #44264...