Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/debug-certificate-manager",
"comment": "Add message to use VS Code extension to errors.",
"type": "patch"
}
],
"packageName": "@rushstack/debug-certificate-manager"
}
13 changes: 10 additions & 3 deletions libraries/debug-certificate-manager/src/CertificateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ export interface ICertificateManagerOptions extends ICertificateStoreOptions {}

const MAX_CERTIFICATE_VALIDITY_DAYS: 365 = 365;

const VS_CODE_EXTENSION_FIX_MESSAGE: string =
'Use the "Debug Certificate Manager" Extension for VS Code (ms-RushStack.debug-certificate-manager) and run the ' +
'"Debug Certificate Manager: Ensure and Sync TLS Certificates" command to fix certificate issues. ';

/**
* A utility class to handle generating, trusting, and untrustring a debug certificate.
* Contains two public methods to `ensureCertificate` and `untrustCertificate`.
Expand Down Expand Up @@ -177,7 +181,8 @@ export class CertificateManager {
if (process.env[DISABLE_CERT_GENERATION_VARIABLE_NAME] === '1') {
// Allow the environment (e.g. GitHub codespaces) to forcibly disable dev cert generation
terminal.writeLine(
`Found environment variable ${DISABLE_CERT_GENERATION_VARIABLE_NAME}=1, disabling certificate generation.`
`Found environment variable ${DISABLE_CERT_GENERATION_VARIABLE_NAME}=1, disabling certificate generation. ` +
VS_CODE_EXTENSION_FIX_MESSAGE
);
canGenerateNewCertificate = false;
}
Expand Down Expand Up @@ -207,7 +212,8 @@ export class CertificateManager {
} else {
validationResult.validationMessages.push(
'Untrust the certificate and generate a new one, or set the ' +
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`.'
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`. ' +
VS_CODE_EXTENSION_FIX_MESSAGE
);
throw new Error(validationResult.validationMessages.join(' '));
}
Expand All @@ -216,7 +222,8 @@ export class CertificateManager {
} else {
throw new Error(
'No development certificate found. Generate a new certificate manually, or set the ' +
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`.'
'`canGenerateNewCertificate` parameter to `true` when calling `ensureCertificateAsync`. ' +
VS_CODE_EXTENSION_FIX_MESSAGE
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class CertificateStore {
storePath = path.resolve(currentDir, debugCertificateManagerConfig.storePath);
}
}
break; // found the config file, stop searching
}
const parentDir: string | undefined = path.dirname(currentDir);
if (parentDir === currentDir) {
Expand Down
Loading