Skip to content

Commit c1005b4

Browse files
authored
Improved detection of cert errors (#82)
1 parent dbf4883 commit c1005b4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/common/request.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Localized } from './localize';
77
import { raceCancellationError } from './async';
88
import { solveCertificateProblem } from './telemetry';
99
import { traceError } from './logging';
10+
import { isSelfCertsError } from '../validator';
1011

1112
/**
1213
* Responsible for intercepting connections to a remote server and asking for a password if necessary
@@ -27,7 +28,7 @@ export class SimpleFetch {
2728
);
2829
} catch (e) {
2930
traceError(`Error sending request to ${url}`, e);
30-
if (e.message.indexOf('reason: self signed certificate') >= 0) {
31+
if (isSelfCertsError(e)) {
3132
// Ask user to change setting and possibly try again.
3233
const value = await window.showErrorMessage(
3334
Localized.jupyterSelfCertFail(e.message),

src/validator.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,12 @@ function isUnableToGetIssuerCertError(err: Error) {
356356
* The URI entry box when picking a server. It should ask the user if they want to allow it anyway.
357357
*/
358358
export function isSelfCertsError(err: Error) {
359-
return err.message.indexOf('reason: self signed certificate') >= 0 || isUnableToGetIssuerCertError(err);
359+
return (
360+
err.message.indexOf('reason: self signed certificate') >= 0 ||
361+
err.message.indexOf("is not in the cert's list") >= 0 ||
362+
err.message.indexOf('reason: unable to verify the first certificate') >= 0 ||
363+
isUnableToGetIssuerCertError(err)
364+
);
360365
}
361366

362367
export async function handleSelfCertsError(message: string): Promise<boolean> {

0 commit comments

Comments
 (0)