Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

feat: add allowUnsafeSSL config for self-signed certificates#306

Closed
lihuanshuai wants to merge 1 commit into
KnisterPeter:masterfrom
lihuanshuai:master
Closed

feat: add allowUnsafeSSL config for self-signed certificates#306
lihuanshuai wants to merge 1 commit into
KnisterPeter:masterfrom
lihuanshuai:master

Conversation

@lihuanshuai
Copy link
Copy Markdown
Contributor

@lihuanshuai lihuanshuai commented Feb 13, 2018

resolve #304

Set github.allowUnsafeSSL to true in workspace settings to overcome https self-signed certificates problem.

@KnisterPeter
Copy link
Copy Markdown
Owner

@lihuanshuai Sorry for late reply. Your code is not compiling right now. Please see the log in travis for the compile error.

Comment thread package.json Outdated
"default": false,
"scope": "resource"
},
"github.rejectUnauthorized": {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to name this allowUnsafeSSL and default it to false.
With that name its much more clear what it does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will modify it later

Comment thread src/provider/client.ts
switch (tokenInfo.provider) {
case 'github':
return new GithubClient(protocol, hostname, tokens[hostname].token, logger);
return new GithubClient(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add it for the gitlab client as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in new commit

Comment thread src/provider/github/client.ts Outdated
constructor(protocol: string, hostname: string, token: string, logger: (message: string) => void) {
this.client = getClient(this.getApiEndpoint(protocol, hostname), token, logger);
constructor(protocol: string, hostname: string, token: string, logger: (message: string) => void,
rejectUnauthoized = false) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should default to true right now I think.
Default default should be to reject invalid ssl chains.

@lihuanshuai
Copy link
Copy Markdown
Contributor Author

@KnisterPeter sorry for late reply. The compiling problem has confused me a lot. I am not quite familar with typing system of typescript. although the error reported, The compiled javascript code worked on my mac.

request is a RequestInit instance. In node_modules/@types/node-fetch/index.d.ts, RequestInit is defined as:

interface RequestInit {
	//whatwg/fetch standard options
	method?: string;
	headers?: HeaderInit | { [index: string]: string };
	body?: BodyInit;
	redirect?: RequestRedirect;

	//node-fetch extensions
	timeout?: number; //=0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)
	compress?: boolean; //=true support gzip/deflate content encoding. false to disable
	size?: number; //=0 maximum response body size in bytes. 0 to disable
	agent?: Agent; //=null http.Agent instance, allows custom proxy, certificate etc.
	follow?: number; //=20 maximum redirect count. 0 to not follow redirect

	//node-fetch does not support mode, cache or credentials options
}

agent field should be ok. but In /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts, which is actually used, RequestInit is defined as:

interface RequestInit {
    signal?: AbortSignal;
    body?: Blob | BufferSource | FormData | string | null;
    cache?: RequestCache;
    credentials?: RequestCredentials;
    headers?: HeadersInit;
    integrity?: string;
    keepalive?: boolean;
    method?: string;
    mode?: RequestMode;
    redirect?: RequestRedirect;
    referrer?: string;
    referrerPolicy?: ReferrerPolicy;
    window?: any;
}

The field is missing in definition, (but actually it exists). I tried installing @types/node-fetch but it didn't work. So, How to fix it?

@KnisterPeter
Copy link
Copy Markdown
Owner

@lihuanshuai I will fix this later, then you can have a look at it.

@lihuanshuai lihuanshuai changed the title feat: add rejectUnauthorized config for self-signed certificates feat: add allowUnsafeSSL config for self-signed certificates Feb 22, 2018
@KnisterPeter
Copy link
Copy Markdown
Owner

@lihuanshuai Nice. I'll fix the compile error and merge it afterwards. Thank for your contribution. 🚀

KnisterPeter added a commit that referenced this pull request Feb 28, 2018
Superseeds #306 and includes it.

Closes #306
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support github enterprise with self-signed certificate

2 participants