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

Add implicit FTPS support #81

Merged
merged 2 commits into from
Oct 15, 2018
Merged

Conversation

oleksandr-kuzmenko
Copy link
Contributor

@oleksandr-kuzmenko oleksandr-kuzmenko commented Oct 9, 2018

SSL support added.

#37

@codecov
Copy link

codecov bot commented Oct 9, 2018

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
+ Coverage   94.01%   94.02%   +<.01%     
==========================================
  Files           7        7              
  Lines        1688     1690       +2     
==========================================
+ Hits         1587     1589       +2     
  Misses        101      101
Impacted Files Coverage Δ
aioftp/server.py 97.05% <100%> (ø) ⬆️
aioftp/client.py 92.52% <100%> (+0.01%) ⬆️

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 95cd305...267db49. Read the comment docs.

@oleksandr-kuzmenko oleksandr-kuzmenko mentioned this pull request Oct 9, 2018
2 tasks
@asvetlov
Copy link
Member

asvetlov commented Oct 9, 2018

Any chance to add a test?

@oleksandr-kuzmenko
Copy link
Contributor Author

I thought about tests, but I don't know a good way for testing transport without ssl support at the server part. Can you advise me how to implement it?

@pohmelie
Copy link
Collaborator

@Alxpy, thanks for pr!

This pr is ¼ of what should be implemented for saying «we support ftps». There is two modes: explicit and implicit. And two sides: client and server. You implement implicit client ftps. Also, I'm sceptical about ftps, since it is pretty rare. But, anyway, I see no reasons to not to merge.

@asvetlov
I'm also want some good tests for this, but as mentioned: without server side implementation tests are not possible in meaning even if they will be implemented they will mock server. I'm not sure that this will be good tests.

@Alxpy, is there a chance you will implement implicit server side mode, so we can write tests and have half ftps support?

I will wait a day before merge. Maybe someone have strong point to reject this pr or @Alxpy take care of implicit server side support.

@asvetlov
Copy link
Member

You are right, mocked tests are useless for this case

@oleksandr-kuzmenko
Copy link
Contributor Author

@pohmelie thanks for the detailed answer!

I will try to implement implicit server side ftps.

@rsichnyi
Copy link
Contributor

rsichnyi commented Oct 11, 2018

lgtm (server side is useless, imo)

@oleksandr-kuzmenko
Copy link
Contributor Author

Implicit server side FTPS added.

@oleksandr-kuzmenko oleksandr-kuzmenko changed the title Add FTPS support for client Add implicit FTPS support Oct 11, 2018
@oleksandr-kuzmenko
Copy link
Contributor Author

@webknjaz
Copy link
Member

@Alxpy try generating test certs via trustme

@oleksandr-kuzmenko
Copy link
Contributor Author

oleksandr-kuzmenko commented Oct 12, 2018

@webknjaz I tried, trustme certs doesn't work without ssl.match_hostname monkey patching even with Py3.6
Or I did something wrong...

But I can use trustme instead of certs files.

FYI @pohmelie

@webknjaz
Copy link
Member

Why? Did you set up the hostname correctly?

tests/common.py Outdated Show resolved Hide resolved
await client.connect("127.0.0.1", PORT)
await client.login()
await client.download(
_client = aioftp.Client(loop=loop, ssl=client.ssl)
Copy link
Member

Choose a reason for hiding this comment

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

There's no point/value in underscoring bunch of vars.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so how would you like to call a variable?

Copy link
Member

Choose a reason for hiding this comment

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

keep it as is, I didn't realize that it's an "extended boolean"

Copy link
Member

Choose a reason for hiding this comment

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

Oh, that was not about ssl

@webknjaz
Copy link
Member

webknjaz commented Oct 12, 2018

@Alxpy

ssl_context = ...
...
...
ca = trustme.CA()
ca.issue_server_cert(u'127.0.0.1')
ca.configure_trust(ssl_context)

@oleksandr-kuzmenko
Copy link
Contributor Author

Yes, I use hostname correctly. And any tests work, but not all.
I got ssl.CertificateError: hostname '::1' doesn't match '127.0.0.1'

@webknjaz
Copy link
Member

oh, that's easy

@webknjaz
Copy link
Member

@Alxpy

ssl_context = ...
...
...
ca = trustme.CA()
ca.issue_server_cert(u'127.0.0.1', u'::1', u'localhost')  # list all incarnations of localhost
ca.configure_trust(ssl_context)

Ref: https://trustme.readthedocs.io/en/latest/#trustme.CA.issue_server_cert

@oleksandr-kuzmenko
Copy link
Contributor Author

trustme works fine, thx

@pohmelie
Copy link
Collaborator

So... @webknjaz @rsichny @asvetlov you think this pr is ready to merge? lgtm. I'm pretty confused, that implicit ftps was so easy to implement.
Hats off to @Alxpy 🎩

await client.connect("127.0.0.1", PORT)
await client.login()
await client.download(
_client = aioftp.Client(loop=loop, ssl=client.ssl)
Copy link
Member

Choose a reason for hiding this comment

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

Undo underscoring of client var. It's not related, nor needed.

@webknjaz
Copy link
Member

@pohmelie FTPS seems to be just plain old FTP on top of TLS, nothing more. So stick SSL between TCP and the app and you're done. Simple and elegant.
SFTP would be a different story, though, as it works on top of SSH.

@Alxpy I insist that wholesale renaming of client to _client in tests is useless and not necessary. It enlarges the diff and brings no value to tests at all.

@pohmelie
Copy link
Collaborator

@webknjaz
I thought at first about explicit ftps: go to secure connection on unsecure command. That sounds pretty hard. Since there must be a method to go down to unsecure from secure. Of course, implicit ftps was pretty straight, but I did not mind, that it is so easy to implement.

@oleksandr-kuzmenko
Copy link
Contributor Author

I insist ...

@webknjaz you can try rename _client to client and understand the reason for this change.

@webknjaz
Copy link
Member

@Alxpy so tell me: what is that?

@webknjaz
Copy link
Member

Oh, I see. You're messing with scopes...

@pohmelie pohmelie merged commit 09958d1 into aio-libs:master Oct 15, 2018
@pohmelie
Copy link
Collaborator

@Alxpy Thank you for great contribution! 🎉

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.

5 participants