Error connecting to IIS server running PU using Visual Studio Code Extension

Hi there,

So as the title says, I’m trying to connect to my PowerShell Universal IIS instance using the extension for Visual Studio Code and I get the following error:

image

The site is running on https, port 5000, with a server self signed certificate which I then imported to my machine.
Settings are as follows:
{
“name”: “Puniversal”,
“url”: “https://puniversal.devereandpartners.local:5000”,
“appToken”: “App Token Here”
}

I tried connecting to the server using invoke-request using the token and got:

StatusCode : 200
StatusDescription : OK

Any ideas please?

Product: PowerShell Universal
Version: 3.0.3

You might be able to try the following setting in your VS Code settings.

        {
            "name": "Local",
            "url": "http://localhost:5000",
            "appToken": "sfdsaf",
            "allowInvalidCertificate": true
        }

Where are you installing the self-signed cert? (machine\user?)

Hi Adam,

I was wondering if there was a similar setting. It didn’t work, however… Still getting the same error.

Regarding the location of the certificate… well, I ended up putting it in both machine and user repos. Basically trying anything at this point. However I still find it strange that I can happily connect to the site using a browser and it won’t complain… but not with Visual Studio Code :-/

I can look into this. We aren’t doing anything too fancy with the extension. The axios package is just being used to query stuff in PSU so there must be some additional configuraition that needs to be done.

This is an old thread, but I have the exact same issue. Looking at the code you mentioned I see I can add the setting
allowInvalidCertificate to false that might disable rejectUnauthorized and allow for self sighed certs.

It does not. I have imported the certificate into the local machine Trusted Certification Authorities and still getting the ‘unable to verify first cretificate’ error. I can open PSU https url and see the cert now shows valid in the chrome browser.

if (connectionName && connectionName !== 'Default') {
            const connection = settings.connections.find(m => m.name === connectionName);
            if (connection) {
                appToken = connection.appToken;
                url = connection.url;
                rejectUnauthorized = connection.allowInvalidCertificate;
            }
        }