Skip to content

Commit 911fef9

Browse files
committed
docs: describe how to disable ssl verification in readme
1 parent ec5425d commit 911fef9

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,21 @@ var myInstance = new watson.WhateverServiceV1({
222222
});
223223
```
224224

225+
### Configuring the HTTP client
226+
227+
The HTTP client can be configured to disable SSL verification. Note that this has serious security implications - only do this if you really mean to! ⚠️
228+
229+
To do this, set `disable_ssl` to `true` in the service constructor, like below:
230+
231+
```
232+
const discovery = new DiscoveryV1({
233+
url: '<service_url>',
234+
version: '<version-date>',
235+
iam_apikey: '<iam_api_key>',
236+
disable_ssl: true, // this will disable SSL verification for any request made with this object
237+
});
238+
```
239+
225240
## Documentation
226241

227242
You can find links to the documentation at https://console.bluemix.net/developer/watson/documentation. Find the service that you're interested in, click **API reference**, and then select the **Node** tab.

lib/base_service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface UserOptions {
4343
iam_access_token?: string;
4444
iam_apikey?: string;
4545
iam_url?: string;
46-
allow_unauthorized?: boolean;
46+
disable_ssl?: boolean;
4747
}
4848

4949
export interface BaseServiceOptions extends UserOptions {
@@ -151,9 +151,9 @@ export class BaseService {
151151
} else {
152152
this.tokenManager = null;
153153
}
154-
// rejectUnauthorized should only be false if allow_unauthorized is true
154+
// rejectUnauthorized should only be false if disable_ssl is true
155155
// used to disable ssl checking for icp
156-
this._options.rejectUnauthorized = !options.allow_unauthorized;
156+
this._options.rejectUnauthorized = !options.disable_ssl;
157157
}
158158

159159
/**

test/unit/test.base_service.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,25 +265,25 @@ describe('BaseService', function() {
265265
assert(authHeader.startsWith('Basic'));
266266
});
267267

268-
it('should set rejectUnauthorized to `false` if allow_unauthorized is `true`', function() {
268+
it('should set rejectUnauthorized to `false` if `disable_ssl` is `true`', function() {
269269
const instance = new TestService({
270270
username: 'apikey',
271271
password: 'icp-1234',
272-
allow_unauthorized: true,
272+
disable_ssl: true,
273273
});
274274
assert.equal(instance._options.rejectUnauthorized, false);
275275
});
276276

277-
it('should set rejectUnauthorized to `true` if allow_unauthorized is `false`', function() {
277+
it('should set rejectUnauthorized to `true` if `disable_ssl` is `false`', function() {
278278
const instance = new TestService({
279279
username: 'apikey',
280280
password: 'icp-1234',
281-
allow_unauthorized: false,
281+
disable_ssl: false,
282282
});
283283
assert(instance._options.rejectUnauthorized);
284284
});
285285

286-
it('should set rejectUnauthorized to `true` if allow_unauthorized is not set', function() {
286+
it('should set rejectUnauthorized to `true` if `disable_ssl` is not set', function() {
287287
const instance = new TestService({
288288
username: 'apikey',
289289
password: 'icp-1234',

0 commit comments

Comments
 (0)