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

feat: Add --unsafely-treat-insecure-origin-as-secure flag to disable SSL verification #11324

Merged
merged 13 commits into from
Aug 9, 2021
Merged

Conversation

TheAifam5
Copy link
Contributor

@TheAifam5 TheAifam5 commented Jul 7, 2021

This PR corresponds to the issue #1371 which implement additional flag to the cli, tools, core, extensions and runtime allowing a user to define a domain or a list of domains which should be excluded from certificate validation while connecting or performing the HTTPS requests or disable validation completely.

The name noCheckCertificate and derives I found somewhere in issues of Deno repository as an proposal for the naming and decided to stick with it.

I will be out for few weeks and I can not continue the work on this code, but I will be able to accept PR in my repository and will be open for discussion.

The first commit is an actual feature implementation, the second is only about fixing issues reported by ./tools/format.js and ./tools/lint.js and some comment changes - all of the issues reported by those tools are fixed, except the one which I am not able to fix right now.

Those 3 tests are failing for unknown reason:

failures:
    integration::js_unit_tests
    integration::lsp::lsp_large_doc_changes
    integration::timeout_clear

Closes #5931

TODOs:

  • Tests
  • Domain name validation (and IP too?)
  • Cleanup

Thanks for hints @bartlomieju :)

@CLAassistant
Copy link

CLAassistant commented Jul 7, 2021

CLA assistant check
All committers have signed the CLA.

cli/flags.rs Outdated Show resolved Hide resolved
cli/flags.rs Outdated Show resolved Hide resolved
cli/flags.rs Outdated Show resolved Hide resolved
cli/flags.rs Outdated Show resolved Hide resolved
extensions/fetch/Cargo.toml Outdated Show resolved Hide resolved
extensions/fetch/lib.rs Outdated Show resolved Hide resolved
extensions/net/Cargo.toml Outdated Show resolved Hide resolved
extensions/net/ops_tls.rs Outdated Show resolved Hide resolved
runtime/Cargo.toml Outdated Show resolved Hide resolved
@bartlomieju
Copy link
Member

I will be out for few weeks and I can not continue the work on this code, but I will be able to accept PR in my repository and will be open for discussion.

Thanks for opening a PR @TheAifam5; I would love to land this PR for 1.12 that is be to released on Tuesday, would you mind if I push directly to your PR?

@bartlomieju
Copy link
Member

Also there are a lot of unrelated changes across multiple files (looks like clippy warnings), however they are not pointed out by current CI setup, so I will revert them to make this PR a bit slimmer.

@TheAifam5
Copy link
Contributor Author

TheAifam5 commented Jul 8, 2021

@bartlomieju I don’t see problem with that, go ahead ;)

Do I need to add you to my fork ?

The changes were due clippy’s warnings so I decided to „fix” them :) I will next time note that to only fix errors - or how should be such cases handled?

@bartlomieju bartlomieju self-assigned this Jul 8, 2021
@bartlomieju
Copy link
Member

@bartlomieju I don’t see problem with that, go ahead ;)

Do I need to add you to my fork ?

There's no need, as a maintainer I can push to your fork.

The changes were due clippy’s warnings so I decided to „fix” them :) I will next time note that to only fix errors - or how should be such cases handled?

What clippy version are you using? When I run tools/lint.js I get no warnings whatsoever. If we can get the same warnings out of the script, I will be more than a happy for another PR that addresses those.

@TheAifam5
Copy link
Contributor Author

What clippy version are you using? When I run tools/lint.js I get no warnings whatsoever. If we can get the same warnings out of the script, I will be more than a happy for another PR that addresses those.

clippy 0.1.55 (d2b04f07 2021-07-07)

it may be because of the nightly I have set as default.

@bartlomieju
Copy link
Member

What clippy version are you using? When I run tools/lint.js I get no warnings whatsoever. If we can get the same warnings out of the script, I will be more than a happy for another PR that addresses those.

clippy 0.1.55 (d2b04f07 2021-07-07)

it may be because of the nightly I have set as default.

That's probable, I'm running on latest stable and cargo clippy --version gives me: clippy 0.1.53 (53cb7b09 2021-06-17)

@TheAifam5
Copy link
Contributor Author

@bartlomieju What's your plan? What would you like to change here? I might have some spare time and might help a little :)

@bartlomieju
Copy link
Member

@bartlomieju What's your plan? What would you like to change here? I might have some spare time and might help a little :)

@TheAifam5 for now I just rolled back unrelated changes. I will do the proper review shortly and let you know. There's some stuff that's wrong at the first glance (there shouldn't be any changes in core/), but ultimately I think it's just a matter of moving the code around. One thing that needs to be done before we can land it is adding some unit or integration tests.

cli/flags.rs Outdated Show resolved Hide resolved
cli/tools/coverage.rs Outdated Show resolved Hide resolved
core/bindings.rs Outdated Show resolved Hide resolved
core/no_certificate_validation.rs Outdated Show resolved Hide resolved
extensions/fetch/lib.rs Outdated Show resolved Hide resolved
extensions/net/lib.rs Outdated Show resolved Hide resolved
extensions/net/ops_tls.rs Outdated Show resolved Hide resolved
runtime/Cargo.toml Outdated Show resolved Hide resolved
core/Cargo.toml Outdated Show resolved Hide resolved
@crowlKats
Copy link
Member

shouldnt this also apply for websocket?

@TheAifam5
Copy link
Contributor Author

TheAifam5 commented Jul 9, 2021

shouldnt this also apply for websocket?

Let me check that :)

EDIT:
@crowlKats should work now

extensions/net/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

@TheAifam5 this PR looks mostly good to me - I pointed out a few things that I don't understand why they're needed. Once those point are addresses I'll help you out with refactoring the code to not change deno_core.

That said, there are tens of files that are changed that are not in any way related to this PR. Please revert those changes. (I believe these might be caused by clippy, but since CI on main branch doesn't complain, these changes should be removed)

core/allow_insecure_certificates_deserializer.rs Outdated Show resolved Hide resolved
core/no_certificate_verification.rs Outdated Show resolved Hide resolved
extensions/net/lib.rs Outdated Show resolved Hide resolved
extensions/net/lib.deno_net.d.ts Outdated Show resolved Hide resolved
extensions/net/ops_tls.rs Outdated Show resolved Hide resolved
@TheAifam5
Copy link
Contributor Author

Will do it :)

@bartlomieju
Copy link
Member

#11491 should be landed first, it will provide extensions/tls crate, which will be a good place to put shared verification code.

@bartlomieju
Copy link
Member

@TheAifam5 after landing #11491 I will rebase you PR

cli/file_fetcher.rs Outdated Show resolved Hide resolved
cli/dts/lib.deno.unstable.d.ts Outdated Show resolved Hide resolved
core/Cargo.toml Outdated Show resolved Hide resolved
core/lib.rs Outdated Show resolved Hide resolved
extensions/fetch/lib.rs Outdated Show resolved Hide resolved
extensions/net/02_tls.js Outdated Show resolved Hide resolved
@bartlomieju bartlomieju changed the title feat: add initial support for disabling certificate validation for specified domain names feat: Add --dangerous-allow-insecure-certificates flag to disable SSL verification Aug 7, 2021
@bartlomieju bartlomieju marked this pull request as ready for review August 7, 2021 21:33
@bartlomieju bartlomieju changed the title feat: Add --dangerous-allow-insecure-certificates flag to disable SSL verification feat: Add --unsafely-treat-insecure-origin-as-secure flag to disable SSL verification Aug 9, 2021
cli/program_state.rs Outdated Show resolved Hide resolved
@bartlomieju bartlomieju requested a review from ry August 9, 2021 10:47
extensions/websocket/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - nice work @TheAifam5 !

@bartlomieju bartlomieju merged commit 353a4a1 into denoland:main Aug 9, 2021
@TheAifam5
Copy link
Contributor Author

Thank you for finishing my work @bartlomieju and @ry for such kind words.

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

Successfully merging this pull request may close these issues.

Override "Bad" SSL Certificate Rejections
7 participants