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 support for custom certificate authority and client certificates #1325

Merged
merged 9 commits into from
Oct 22, 2019
Merged

Add support for custom certificate authority and client certificates #1325

merged 9 commits into from
Oct 22, 2019

Conversation

Caligatio
Copy link
Contributor

@Caligatio Caligatio commented Aug 25, 2019

  • Added tests for changed code.
  • Updated documentation for changed code.

This PR adds support for specifying a custom certificate authority to validate custom repositories as well as using client certificate-based authentication for custom repos. This was quite a bit bigger than I anticipated but I think I plumbed everything that is needed.

This should address #1012 and #297

@Caligatio Caligatio changed the title Cert auth Add support for custom certificate authority and client certificates Aug 25, 2019
@brycedrennan brycedrennan added the kind/feature Feature requests/implementations label Aug 25, 2019
@Caligatio
Copy link
Contributor Author

@brycedrennan I realize this is a substantial PR but I just successfully used my branch to both push and pull to a mutual TLS authenticated repository. This unfortunately is a blocker for my major use case of Poetry so please let me know I can help this along.

@brycedrennan
Copy link
Contributor

Thanks for your work on this feature! Unfortunately, we're rather behind on merges so it may be a while till we get to this.

@@ -14,6 +16,18 @@ class PublishCommand(Command):
),
option("username", "u", "The username to access the repository.", flag=False),
option("password", "p", "The password to access the repository.", flag=False),
option(
"custom-ca",
Copy link

Choose a reason for hiding this comment

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

minor -- consider using curl or twine's syntax

--cacert, --cert, --key

or

--cert, --client-cert with client-cert being a combined pem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I probably struggled the most with naming the silly parameters compared to anything else about this PR. I started with custom-ca, hated it, but then figured we could come to consensus in the PR itself :)

Since I'm interfacing with both requests and pip under the hood, I need to use a combined client cert/key file as that's the only thing both take (pip is the picky one). That being said, I liked pip's --client-cert and went with it.

For CA:

  • Twine (as you noted) uses --cacert
  • pip (as you noted) uses --cert
  • cURL uses --cacert
  • wget uses --ca-certificate
  • requests uses the parameter verify (that's terrible)
  • Python's built-in ssl module uses the parameter cafile
  • urllib3 uses the parameter ca_certs

Since I did --client-cert (with the hyphen in between), I'm thinking it should be consistent and be --ca-<SOMETHING> but that looks weird too. I'm happy to change it to anything that the maintainers will accept; I fully recognize --custom-ca is not great.

Copy link
Member

Choose a reason for hiding this comment

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

I think we can follow what's already used in both pip and twine, i.e. --cert and --client-cert.

@Caligatio Caligatio mentioned this pull request Aug 31, 2019
2 tasks
@Caligatio
Copy link
Contributor Author

I changed the name and was very confident everything would continue working, however, there were major changes to develop that make me less confident.

@Caligatio
Copy link
Contributor Author

Checked it today and it both pulls packages using certs and will publish. Confidence restored!

@broken-wheel
Copy link

@Caligatio , @brycedrennan, any updates on this PR? Thank you.

@Caligatio
Copy link
Contributor Author

I consider it done and am just waiting on it to be merged.

Copy link

@b0g3r b0g3r left a comment

Choose a reason for hiding this comment

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

LGTM

Awesome feature, we in team waited a very long time for.

@sdispater
Copy link
Member

@Caligatio Thanks for your contribution!

I am ready to merge this to include it in the 1.0 release. Could you rebase your branch onto master?

@Caligatio Caligatio changed the base branch from develop to master October 20, 2019 18:48
@Caligatio
Copy link
Contributor Author

Rebased to master and merged in the changes. Should be good to go!

@sdispater sdispater merged commit 4d1e975 into python-poetry:master Oct 22, 2019
@sdispater
Copy link
Member

Thanks!

michielboekhoff pushed a commit to michielboekhoff/poetry that referenced this pull request Oct 29, 2019
…ython-poetry#1325)

* Add custom certificate authority and client certificate support

* Add documentation on certificates

* Add cli options to publish for cert and custom ca

* Fix requests+pathlib problem and logic hole when BasicAuth+certs are used

* Rename custom-ca to cert

* Make black happy
michielboekhoff pushed a commit to michielboekhoff/poetry that referenced this pull request Oct 29, 2019
…ython-poetry#1325)

* Add custom certificate authority and client certificate support

* Add documentation on certificates

* Add cli options to publish for cert and custom ca

* Fix requests+pathlib problem and logic hole when BasicAuth+certs are used

* Rename custom-ca to cert

* Make black happy
@pawamoy
Copy link

pawamoy commented Dec 27, 2019

Is this released in version 1.0?

EDIT: it is, no need to answer 🙂

Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants