GithubHelp home page GithubHelp logo

lxyu / backports.ssl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alekstorm/backports.ssl

0.0 1.0 0.0 43 KB

The Python 3.4 standard `ssl` module API implemented on top of pyOpenSSL

License: Other

Python 100.00%

backports.ssl's Introduction

backports.ssl

What is it?

It's the Python 3.4 standard ssl module API implemented on top of pyOpenSSL:

import backports.ssl as ssl
import socket

context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_REQUIRED

conn = context.wrap_socket(socket.socket(socket.AF_INET))
conn.connect(('google.com', 443))
print conn.getpeercert()
conn.close()

Why?

Because the latest web technologies should be available to those running older versions of Python.

Isn't this obsoleted by PEP 466?

If you're on Python 2.7, then probably. But PEP 466 doesn't cover Python 2.6, 3.2, or 3.3, and the ssl.RAND_*() functions are explicitly out of scope. This package supports it all.

How do I use it with third-party libraries?

Monkey-patching support is included a la gevent:

import backports.ssl.monkey as monkey
import requests

monkey.patch()
requests.get('https://google.com')

Why am I getting AttributeErrors for newer features?

Like the standard ssl module, certain attributes will not be available if your OpenSSL does not support them. See Installing OpenSSL for instructions.

Installing OpenSSL

TODO

  • Verify that we play nicely with gevent's monkey-patching.
  • Backport and pass the standard Python ssl test suite.
  • If not that, automate testing against hyper, urllib3, requests, and Tornado test suites.
  • Use the bundled 3.x OpenSSL, if available and newer than the default.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.