@JupyterLab Services and SSL self signed certs and rejectUnauthorized

Hey everyone. I had a question that I was beating my head a bit on regarding @JuypterLab’s connection services. Currently we are using those services in a Node.js client application to connect to running jupyter notebook servers, and they have been super helpful for that. But we are having an issue with connecting to a server running self signed certs. In the browser you’ll get a warning message for a connection like that, but you can ignore that message if you choose and proceed to the site. However for using the services we get a message that our connection was rejected due to self-signed certs with no particular way around it. I’m trying now to add an option to the client to allow that type of connection.

What I’ve been trying now is something like this (previously we were not specifying an agent at all):

        const requestAgent = new HttpsAgent({rejectUnauthorized: false });
        const requestOptions: any = { cache: 'no-store', credentials: 'same-origin', agent: requestAgent };

        const serverSettings = ServerConnection.makeSettings(
            {
                baseUrl: this.connInfo.baseUrl,
                token: this.connInfo.token,
                pageUrl: '',
                // A web socket is required to allow token authentication
                wsUrl: this.connInfo.baseUrl.replace('http', 'ws'),
                init: requestOptions
            });

        this.contentsManager = new ContentsManager({ serverSettings: serverSettings });
        this.notebookFile = await this.contentsManager.newUntitled({type: 'notebook'});

When I run this code against the self signed notebook server it seems like it might start to work (I can see the temp ipynb get created and a connection start via the SessionManager) and I don’t get the self cert failure message. But then after that the server seems to go into some type of odd loop where it’s always in a “reconnecting” status on the kernel. We generally wait until we see an idle kernel before we start to send code, so I’m not sure what’s going on here. I would have expect it to not connect at all if I was specifying something incorrect, but it does seem to connect before getting stuck in that reconnecting state. Any ideas on this?