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

Provide access to the validated certificate chain in ssl module #69715

Closed
Lukasa mannequin opened this issue Nov 1, 2015 · 4 comments
Closed

Provide access to the validated certificate chain in ssl module #69715

Lukasa mannequin opened this issue Nov 1, 2015 · 4 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@Lukasa
Copy link
Mannequin

Lukasa mannequin commented Nov 1, 2015

BPO 25529
Nosy @pitrou, @giampaolo, @tiran, @alex, @bitdancer, @dstufft, @Lukasa
Superseder
  • bpo-24107: Add support for retrieving the certificate chain
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-06-11.14:22:09.886>
    created_at = <Date 2015-11-01.18:39:40.249>
    labels = ['type-feature', 'library']
    title = 'Provide access to the validated certificate chain in ssl module'
    updated_at = <Date 2016-06-11.14:22:09.885>
    user = 'https://github.com/Lukasa'

    bugs.python.org fields:

    activity = <Date 2016-06-11.14:22:09.885>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-06-11.14:22:09.886>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2015-11-01.18:39:40.249>
    creator = 'Lukasa'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 25529
    keywords = []
    message_count = 4.0
    messages = ['253864', '255986', '255987', '256023']
    nosy_count = 9.0
    nosy_names = ['janssen', 'pitrou', 'giampaolo.rodola', 'christian.heimes', 'alex', 'r.david.murray', 'dstufft', 'Lukasa', 'rugk']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '24107'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25529'
    versions = ['Python 3.6']

    @Lukasa
    Copy link
    Mannequin Author

    Lukasa mannequin commented Nov 1, 2015

    I’m currently working on adding support for HPKP to the Requests and urllib3 modules. HPKP (HTTP Public Key Pinning), specified in RFC 7469, is an extension to HTTP that allows a web server to specify a whitelist of public keys that are valid for TLS certificates on that domain. This prevents a rogue certificate authority from issuing a certificate that would be trusted by a browser and would allow a man-in-the-middle attack on a domain (as happened to Google in 20130).

    Right now, the draft version of the support I have will only work when you use PyOpenSSL for your TLS needs, not the standard library. This is because to get HPKP to work I need access to the validated certificate chain: that is, the certificate chain that OpenSSL has built and validated for the TLS connection. I also need to be able to work with those certificates in order to extract their public keys. The standard library’s ssl module does not expose any of this functionality.

    To get this to work with the standard library, I would require the following things from the standard library:

    1. The ability to access the validated certificate chain. This requires saving off the certificate each time the OpenSSL verify callback is called. This is an easy enough change to make.
    2. The ability to extract the public key from the saved certificates. This could be done by extending the logic used for getpeercert() to provide a DER-encoded ASN.1 representation of the public key in the dictionary, and then using that representation for each cert in the peer cert chain.

    The motivation for making this available in the standard library would be pip. Right now python.org and all its subdomains (including pypi.python.org) are HPKP-enabled. Making this support available in the standard library would ensure that all pip installations are safe from man-in-the-middle attacks on its packaging infrastructure. Without it, a number of third-party packages would be required to add this security. In particular, pip could distribute a HPKP preload value for pypi.python.org, which would ensure that pip is truly invulnerable to MITM TLS attacks via malicious attackers coercing a CA to provide TLS certificates for *.python.org.

    I’m happy to do the work required to provide this functionality, but I’d only like to start work if people believe there’s a likelihood of getting it merged.

    @Lukasa Lukasa mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Nov 1, 2015
    @rugk
    Copy link
    Mannequin

    rugk mannequin commented Dec 5, 2015

    Very nice idea. But no developer/maintainer seems to have until now, so I'll just like to ask whether there are any news regarding this issue.

    @rugk
    Copy link
    Mannequin

    rugk mannequin commented Dec 5, 2015

    Oops, forgot a word:
    *"seems to have until now" to "seems to have replied until now"

    @bitdancer
    Copy link
    Member

    If there's no reply, that would be a no :)

    So, pinging the issue after a month as you just did is appropriate, let's see if one of the openssl experts replies.

    On the other hand, how is this different from bpo-24107, where Crys did reply?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants