Skip to content

Tweak certificate errors #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## Unreleased

### Changes

- Show certificate errors under the token input.

## [v0.1.36](https://github.com/coder/vscode-coder/releases/tag/v0.1.36) (2024-04-09)

### Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"displayName": "Coder",
"description": "Open any workspace with a single click.",
"repository": "https://github.com/coder/vscode-coder",
"version": "0.1.36",
"version": "0.1.37",
"engines": {
"vscode": "^1.73.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class Commands {
err.showNotification()

return {
message: err.message,
message: err.x509Err || err.message,
severity: vscode.InputBoxValidationSeverity.Error,
}
}
Expand Down
21 changes: 7 additions & 14 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export enum X509_ERR_CODE {

// X509_ERR contains human-friendly versions of TLS errors.
export enum X509_ERR {
PARTIAL_CHAIN = "Your Coder deployment's certificate cannot be verified because a certificate is missing from its chain. To fix this your deployment's administrator should bundle the missing certificates or you can add the missing certificates directly to this system's trust store.",
PARTIAL_CHAIN = "Your Coder deployment's certificate cannot be verified because a certificate is missing from its chain. To fix this your deployment's administrator must bundle the missing certificates.",
// NON_SIGNING can be removed if BoringSSL is patched and the patch makes it
// into the version of Electron used by VS Code.
NON_SIGNING = "Your Coder deployment's certificate is not marked as being capable of signing. VS Code uses a version of Electron that does not support certificates like this even if they are self-issued. The certificate should be regenerated with the certificate signing capability.",
UNTRUSTED_LEAF = "Your Coder deployment's certificate does not appear to be trusted by this system. The certificate should be added to this system's trust store.",
UNTRUSTED_CHAIN = "Your Coder deployment's certificate chain does not appear to be trusted by this system. The root of the certificate chain should be added to this system's trust store. ",
NON_SIGNING = "Your Coder deployment's certificate is not marked as being capable of signing. VS Code uses a version of Electron that does not support certificates like this even if they are self-issued. The certificate must be regenerated with the certificate signing capability.",
UNTRUSTED_LEAF = "Your Coder deployment's certificate does not appear to be trusted by this system. The certificate must be added to this system's trust store.",
UNTRUSTED_CHAIN = "Your Coder deployment's certificate chain does not appear to be trusted by this system. The root of the certificate chain must be added to this system's trust store. ",
}

export interface Logger {
Expand All @@ -31,7 +31,7 @@ interface KeyUsage {

export class CertificateError extends Error {
public static ActionAllowInsecure = "Allow Insecure"
public static ActionViewMoreDetails = "View More Details"
public static ActionOK = "OK"
public static InsecureMessage =
'The Coder extension will no longer verify TLS on HTTPS requests. You can change this at any time with the "coder.insecure" property in your VS Code settings.'

Expand Down Expand Up @@ -116,12 +116,6 @@ export class CertificateError extends Error {
})
}

viewMoreDetails(): Thenable<boolean> {
return vscode.env.openExternal(
vscode.Uri.parse("https://github.com/coder/vscode-coder/issues/115#issuecomment-1631512493"),
)
}

// allowInsecure updates the value of the "coder.insecure" property.
async allowInsecure(): Promise<void> {
vscode.workspace.getConfiguration().update("coder.insecure", true, vscode.ConfigurationTarget.Global)
Expand All @@ -146,11 +140,10 @@ export class CertificateError extends Error {
// inside VS Code. Disabling the "Strict SSL" setting does not help
// either. For now avoid showing the button until this is sorted.
// CertificateError.ActionAllowInsecure,
CertificateError.ActionViewMoreDetails,
CertificateError.ActionOK,
)
switch (val) {
case CertificateError.ActionViewMoreDetails:
await this.viewMoreDetails()
case CertificateError.ActionOK:
return
case CertificateError.ActionAllowInsecure:
await this.allowInsecure()
Expand Down