Skip to content

Disable ssl for websocket #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 28, 2018
Merged

Disable ssl for websocket #782

merged 6 commits into from
Sep 28, 2018

Conversation

dpopp07
Copy link
Contributor

@dpopp07 dpopp07 commented Sep 27, 2018

The SSL disabling option I added for the last release did not cover the WebSocket connection (thanks @lpatino10 for the catch).

This PR resolves this by taking the user option, passing it to the RecognizeStream class, and using it to configure the connection. It does this by creating a tlsOptions parameter, which gets passed into Node's native http library according to the websocket docs.

@lpatino10 confirmed this fix works with ICP.

cc @germanattanasio

@@ -117,6 +117,7 @@ class RecognizeStream extends Duplex {
* @param {string} [options.base_model_version] - The version of the specified base model that is to be used with recognition request or, for the **Create a session** method, with the new session.
* Multiple versions of a base model can exist when a model is updated for internal improvements. The parameter is intended primarily for use with custom models that have been upgraded for a new base model.
* The default value depends on whether the parameter is used with or without a custom model. For more information, see [Base model version](https://console.bluemix.net/docs/services/speech-to-text/input.html#version).
* @param {Boolean} [options.rejectUnauthorized] - If true, disable SSL verification for the WebSocket connection
Copy link
Contributor

Choose a reason for hiding this comment

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

is rejectUnauthorized the name we use in the other SDKs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the name of the parameter for the request objects, so it's used internally but it's not user-facing. The user passes in a parameter called disable_ssl, and rejectUnauthorized just becomes the opposite of whatever Boolean value is passed in.

Java is using disableSslVerification. Not sure about the other SDKs. I can change the parameter name to disable_ssl_verification to be consistent if you think I should.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed 👍

const socket = (this.socket = new w3cWebSocket(
url,
null,
null,
options.headers,
null
null,
options.rejectUnauthorized ? { tlsOptions: { rejectUnauthorized: false }} : null
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the ternary expressions need to be swapped. Right now we're setting rejectUnauthorized to false if it's true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh shoot I did something silly. I'm not supposed to be setting rejectUnauthorized at all. I'll fix that now.

@codecov-io
Copy link

codecov-io commented Sep 27, 2018

Codecov Report

Merging #782 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #782      +/-   ##
=========================================
+ Coverage    83.2%   83.2%   +<.01%     
=========================================
  Files          36      36              
  Lines        4560    4561       +1     
  Branches      578     578              
=========================================
+ Hits         3794    3795       +1     
  Misses        364     364              
  Partials      402     402
Impacted Files Coverage Δ
lib/recognize-stream.ts 50.92% <ø> (ø) ⬆️
speech-to-text/v1.ts 69.56% <100%> (+0.13%) ⬆️
lib/base_service.ts 83.33% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 724e684...b96e3e6. Read the comment docs.

lpatino10
lpatino10 previously approved these changes Sep 27, 2018
Copy link
Contributor

@lpatino10 lpatino10 left a comment

Choose a reason for hiding this comment

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

Just confirmed that it works on ICP so 👌 👌 👌

@dpopp07 dpopp07 merged commit 69a6f78 into master Sep 28, 2018
@dpopp07 dpopp07 deleted the disable-ssl-for-websocket branch September 28, 2018 14:19
@watson-github-bot
Copy link
Contributor

🎉 This PR is included in version 3.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants