Skip to content

Add the ssl stdlib module - #1823

Merged
coolreader18 merged 17 commits into
masterfrom
coolreader18/stdlib-ssl
Apr 1, 2020
Merged

Add the ssl stdlib module#1823
coolreader18 merged 17 commits into
masterfrom
coolreader18/stdlib-ssl

Conversation

@coolreader18

@coolreader18 coolreader18 commented Mar 21, 2020

Copy link
Copy Markdown
Member

This is all VERY flaky, with many uses of unsafe. I'm not sure if this is a good idea at this point, but it does work, albeit not certificate verification. EDIT: certificate verification does work, just not with google.com. @palaviv what's the deal? 😄

from urlllib.request import urlopen
print(urlopen("https://rustpython.github.io").read().decode())

@coolreader18
coolreader18 force-pushed the coolreader18/stdlib-ssl branch 8 times, most recently from a61f0ed to a37c9c8 Compare March 22, 2020 04:09
@coolreader18
coolreader18 marked this pull request as ready for review March 22, 2020 04:13
@coolreader18

Copy link
Copy Markdown
Member Author

Okay, I think this is in half-decent shape now. If anyone has experience with openssl, I'd love to hear any ideas about why certificate verification isn't working.

@coolreader18

Copy link
Copy Markdown
Member Author

Nevermind, certificate verification does work, just not with google.com for some reason.

@palaviv palaviv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very impressive work!!!

Comment thread Lib/test/test_bytes.py Outdated
Comment thread vm/Cargo.toml
num_cpus = "1"
socket2 = { version = "0.3", features = ["unix"] }
rustyline = "6.0"
openssl = "0.10"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Have we considered something pure rust? Maybe RusTLS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I looked into it, but _ssl's API pretty directly corresponds to OpenSSL's API; I don't think it would be guaranteed that everything we needed would be present in rustls.

Comment thread vm/src/obj/objset.rs Outdated
@coolreader18
coolreader18 force-pushed the coolreader18/stdlib-ssl branch from 95e92fe to 509ac5a Compare March 27, 2020 16:03
Comment thread vm/src/pyobject.rs
Comment thread vm/src/stdlib/ssl.rs Outdated
@coolreader18
coolreader18 force-pushed the coolreader18/stdlib-ssl branch from 509ac5a to 5b7ee53 Compare March 27, 2020 17:41
@coolreader18
coolreader18 force-pushed the coolreader18/stdlib-ssl branch from 5b7ee53 to 1486b65 Compare March 27, 2020 19:40
@coolreader18
coolreader18 force-pushed the coolreader18/stdlib-ssl branch from 277ac0b to d10714d Compare March 27, 2020 20:24
@coolreader18

Copy link
Copy Markdown
Member Author

Is this good to merge?

Comment thread vm/src/stdlib/ssl.rs Outdated
#[pymethod]
fn set_ciphers(&self, cipherlist: PyStringRef, vm: &VirtualMachine) -> PyResult<()> {
let ciphers = cipherlist.as_str();
if ciphers.contains('0') {

@youknowone youknowone Mar 30, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

probably ciphers.contains(0 as char)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

😳 yep, I meant '\0'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

having a test for this method call will be good to ensure this is correctly working

@coolreader18

Copy link
Copy Markdown
Member Author

Also, would it be best to vendor openssl by using the vendored feature for rust-openssl? It would increase binary size, but it would also get rid of a lot of issues with linking to openssl (I don't think any of the weird Windows stuff would be necessary). Maybe best to only vendor on windows, if possible?

@youknowone

Copy link
Copy Markdown
Member

I have no idea about rust-openssl part but this PR looks good to me

@coolreader18
coolreader18 force-pushed the coolreader18/stdlib-ssl branch from d10714d to 7051b25 Compare April 1, 2020 03:40
@coolreader18

Copy link
Copy Markdown
Member Author

I think I'll look into vendoring-only-on-windows by contributing something to rust-openssl, I don't think it's possible otherwise, and it works for now.

@coolreader18
coolreader18 merged commit c1c9631 into master Apr 1, 2020
@coolreader18
coolreader18 deleted the coolreader18/stdlib-ssl branch April 1, 2020 16:34
@palaviv

palaviv commented Apr 4, 2020

Copy link
Copy Markdown
Contributor

Also, would it be best to vendor openssl by using the vendored feature for rust-openssl? It would increase binary size, but it would also get rid of a lot of issues with linking to openssl (I don't think any of the weird Windows stuff would be necessary). Maybe best to only vendor on windows, if possible?

This fails on my PC without the vendored feature. I would suggest adding this by default to avoid problems with different systems and versions of OpenSSL.

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.

3 participants