Skip to content
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

[FIX] Fix set avatar http call, to avoid SSL errors #12790

Merged
merged 1 commit into from
Dec 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/functions/setUserAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RocketChat.setUserAvatar = function(user, dataURI, contentType, service) {
let result = null;

try {
result = HTTP.get(dataURI, { npmRequestOptions: { encoding: 'binary' } });
result = HTTP.get(dataURI, { npmRequestOptions: { encoding: 'binary', rejectUnauthorized: false } });
Copy link
Contributor

Choose a reason for hiding this comment

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

I don’t know that this really solves the issue. It just makes it so invalid ssl doesn’t hold it up. But what if a server instead did something else to cause major delay in response?

Also, do we really want to ignore invalid ssl?

I wonder if instead we could make window shorter that it will wait on a response?

Copy link
Contributor

@wreiske wreiske Dec 3, 2018

Choose a reason for hiding this comment

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

Yikes! Please never use rejectUnauthorized unless there is a system setting that allows system admins to not check SSL certs.

"By setting rejectUnauthorized: false, you're saying "I don't care if I can't verify the server's identity." Obviously this is not a good solution as it leaves you vulnerable to MITM attacks."

https://stackoverflow.com/questions/31861109/tls-what-exactly-does-rejectunauthorized-mean-for-me

Just as a note, Meteor's default behavior for HTTP.get is an unlimited timeout. https://docs.meteor.com/api/http.html

Copy link
Contributor

Choose a reason for hiding this comment

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

That’s basically what this is doing. It’s explicitly saying not to use rejectUnauthorized. It’s true by default if not specified.

I agree though if anything it should be admin option.

But I stand by that there has to be a better way to solve the issue. Since the issue isn’t necessarily about invalid ssl. But more about the server hanging

} catch (error) {
if (!error.response || error.response.statusCode !== 404) {
console.log(`Error while handling the setting of the avatar from a url (${ dataURI }) for ${ user.username }:`, error);
Expand Down