From 42d85a3a73d677a44d9e9b457e03e122102dd904 Mon Sep 17 00:00:00 2001 From: Ev Haus Date: Tue, 29 Jan 2019 13:49:39 -0800 Subject: [PATCH 1/3] Update README.md with `rejectUnauthorized` After upgrading my version of `node-gitlab` I noticed that I the API broke as result of these error messages: `Error: self signed certificate`. I was really confused why this was happening even though I had `process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';` set in my file. Turns out this work https://github.com/jdalrymple/node-gitlab/issues/142 added a special flag to Gitlab's BaseModel to specifically handle rejections of certificates. This PR adds documentation for it so that others running into this issue won't waste their time going down the same rabbit hole I went on. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14592cfd..dbc38724 100644 --- a/README.md +++ b/README.md @@ -148,8 +148,9 @@ const Gitlab = require('gitlab/dist/es5').default // Instantiating const api = new Gitlab({ - url: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456' // Can be created in your profile. + url: 'http://example.com', // Defaults to https://gitlab.com + token: 'abcdefghij123456', // Can be created in your profile. + rejectUnauthorized: false // Should insecure certificates be rejected (true by default) }) // Or, use a OAuth token instead! From 91c9cdf6ef78e40a13de904382e46808b35cb208 Mon Sep 17 00:00:00 2001 From: Ev Haus Date: Wed, 30 Jan 2019 07:41:00 -0800 Subject: [PATCH 2/3] Updates to doc to address pull request feedback --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dbc38724..857caa9b 100644 --- a/README.md +++ b/README.md @@ -148,9 +148,8 @@ const Gitlab = require('gitlab/dist/es5').default // Instantiating const api = new Gitlab({ - url: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456', // Can be created in your profile. - rejectUnauthorized: false // Should insecure certificates be rejected (true by default) + url: 'http://example.com', // Defaults to https://gitlab.com + token: 'abcdefghij123456' // Can be created in your profile. }) // Or, use a OAuth token instead! @@ -269,6 +268,28 @@ EpicNotes EpicDiscussions ``` +#### Handling HTTPS certificates + +If your Gitlab server is running via HTTPS, the proper way to pass in your certificates is via a `NODE_EXTRA_CA_CERTS` environment key, like this: + +```js +"scripts": { + "start": "NODE_EXTRA_CA_CERTS=./secrets/3ShapeCA.pem node bot.js" +}, +``` + +Although we don't encourage it, if you absolutely must allow insecure certificates, you can instantiate the API with `rejectAuthorized` set to `true` like this: + +``` +const api = new Gitlab({ + url: '...', + token: '...', + rejectUnauthorized: true +}) +``` + +> **NOTE**: _Using `process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'` will not work with the `gitlab` library. The `rejectUnauthorized` key is the only way to allow insecure certificates to be bypassed._ + ### Using XMLHttpRequest This package uses the [Request](https://github.com/request/request) library by default, which is built into Node. However, if your code is running in a browser, you can get better built-in resolution of proxies and self-signed certificates by using the browser's XMLHttpRequest implementation instead: From 25dc58b998efae18ddd1f3ef38a3e13cca55ff52 Mon Sep 17 00:00:00 2001 From: Ev Haus Date: Wed, 30 Jan 2019 07:41:48 -0800 Subject: [PATCH 3/3] Minor reset --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 857caa9b..f60cc17f 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ const Gitlab = require('gitlab/dist/es5').default // Instantiating const api = new Gitlab({ url: 'http://example.com', // Defaults to https://gitlab.com - token: 'abcdefghij123456' // Can be created in your profile. + token: 'abcdefghij123456' // Can be created in your profile. }) // Or, use a OAuth token instead!