-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3730b7d
commit 54e63bd
Showing
6 changed files
with
53 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { workspace, ConfigurationTarget } from 'vscode'; | ||
import * as vscode from 'vscode'; | ||
|
||
export async function certConfigHack(): Promise<void> { | ||
// See https://github.com/krinql/vscode/issues/1 | ||
// and https://github.com/microsoft/vscode/issues/136787 | ||
if (workspace.getConfiguration('http').get<boolean>('systemCertificates')) { | ||
// Set a sentinel so that we know that we set it rather than the user, and thus we can revert it later. | ||
await workspace.getConfiguration('krinql').update('httpSystemCertificatesHotFix', true, ConfigurationTarget.Global); | ||
await workspace.getConfiguration('http').update('systemCertificates', false, ConfigurationTarget.Global); | ||
// Setting docs say that a window reload is required for it to take effect. | ||
vscode.window.showInformationMessage('Attempting to apply patch for SSL Error, Window will reload'); | ||
await vscode.commands.executeCommand('workbench.action.reloadWindow'); | ||
} | ||
// Already tried applying the hack and it didn't work, so give up. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as vscode from 'vscode'; | ||
import { LOGIN_URL } from '../config'; | ||
import {certConfigHack} from './certErrorHotfix'; | ||
export async function handleNoResponse(err: any): Promise<void> { | ||
if (!err.response) { | ||
if(err.name === "auth/no-token"){ | ||
vscode.window.showWarningMessage("Please login to your Krinql account.", 'Login') | ||
.then(selection => { | ||
if (selection === 'Login') { | ||
vscode.env.openExternal(vscode.Uri.parse(LOGIN_URL)); | ||
} | ||
}); | ||
} | ||
else if(err?.message?.includes("certificate has expired")){ | ||
// Bugfix Patch/Hack for electron certificate error | ||
// See https://github.com/krinql/vscode/issues/1 | ||
// and https://github.com/microsoft/vscode/issues/136787 | ||
await certConfigHack(); | ||
} | ||
else { | ||
vscode.window.showErrorMessage(`Error Contacting API ${err?.message}`); | ||
} | ||
} | ||
} |