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 SSL support #42

Open
beauremus opened this issue Oct 6, 2021 · 14 comments
Open

Add SSL support #42

beauremus opened this issue Oct 6, 2021 · 14 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@beauremus
Copy link
Contributor

Here's an HTTPS implementation that seems like it could be useful for our socket communications.
https://chaobin.github.io/2015/07/22/a-working-understanding-on-SSL-and-HTTPS-using-python/

@beauremus beauremus added the good first issue Good for newcomers label Oct 6, 2021
@beauremus
Copy link
Contributor Author

If this post can be believed this is a one-line change after importing the SSL module. This would be a good first issue.
https://stackoverflow.com/questions/26851034/opening-a-ssl-socket-connection-in-python

@rneswold rneswold added the enhancement New feature or request label Oct 6, 2021
@potap75
Copy link

potap75 commented Oct 7, 2021

I'll take it, please!

@rneswold
Copy link
Collaborator

rneswold commented Oct 7, 2021

Thanks for volunteering, @potap75 !

@potap75
Copy link

potap75 commented Oct 7, 2021

What should I use as an upstream master? v1.0.0rc6 ?

@beauremus
Copy link
Contributor Author

Yes. That's correct.

@potap75
Copy link

potap75 commented Oct 7, 2021

thank you!

@potap75
Copy link

potap75 commented Oct 7, 2021

I keep getting: "fatal: branch 'master' does not exist"

@potap75
Copy link

potap75 commented Oct 7, 2021

When I'm trying to setup a branch in PyCharm: git branch --set-upstream-to=upstream/v1.0.0rc6

@beauremus
Copy link
Contributor Author

Yes. Branch master doesn't exist. The branches are labeled by major version so you want v1.x.

@rneswold
Copy link
Collaborator

rneswold commented Oct 7, 2021

Strange. We set v1.x to be the default branch so, when you check it out, I would have thought you would get that branch.

@potap75
Copy link

potap75 commented Oct 7, 2021

This is what I get when I try to set a branch:
Screen Shot 2021-10-07 at 5 04 56 PM

@potap75
Copy link

potap75 commented Oct 7, 2021

Anyways. Maybe I can contribute directly here:

import socket
import ssl

hostname = ''
context = ssl.create_default_context()

with socket.create_connection((hostname, 443)) as sock:
    with context.wrap_socket(sock, server_hostname=hostname) as ssock:
        print(ssock.version())

EDIT: Code highlighting

@rneswold
Copy link
Collaborator

rneswold commented Oct 8, 2021

Thank you for the contribution, @potap75.

We're using the async features of Python3 so our TCP socket is hidden in the Transport class. Looking at the 3.10 documentation, I see there's a chance that the asyncio library supports SSL sockets, if we choose the proper set-up options. Hopefully this also works for 3.6.

UPDATE: It looks like we can do something like this:

con_fut = loop.create_connection(lambda: self,
                                 host='acsys-proxy.fnal.gov',
                                 port=self.port,
                                 ssl=True)

@rneswold
Copy link
Collaborator

rneswold commented Oct 8, 2021

e56b8d6 is the proposed change.

We're getting sslv3 handshake errors but, when I point the Python script to a non-DPM SSL server, this code connects. So @charlieking65 and I think it's a config issue on the proxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants