This file contains code for validating certificates using Window's Crypt32 API, rather than OpenSSL. It's intended to go hand-in-hand with my proposed changes to cryptography that will make these bindings accessible, and will later be productised in the certitude module.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
[][-1] | |
except IndexError: | |
pass | |
raise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Notes on draft-ietf-httpauth-extension-05 | |
- Abstract | |
- “This document specifies a few extensions” | |
- The “a few” feels informal to me: consider removing. | |
- “fundamental features of HTTP-level authentication is not enough for complex” | |
- s/is not enough/are insufficient/ | |
- “This makes these applications to implement" | |
- s/makes/forces/ | |
- “user-agent clients” | |
- Are there non-user-agent clients? If not, remove “clients” and just use “user-agents”. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet.protocol import Protocol | |
class PrinterProtocol(Protocol): | |
def connectionMade(self, transport): | |
self.transport = transport | |
self.response = b'' | |
self.transport.write( | |
b'GET / HTTP/1.1\r\n' | |
b'Host: http2bin.org\r\n' | |
b'Connection: close\r\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
def socket_loop(sock): | |
while True: | |
data = sock.recv(8192) | |
print(data) | |
if not data: | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import ssl | |
import time | |
ctx = ssl.create_default_context() | |
ctx.check_hostname = False | |
ctx.verify_mode = ssl.CERT_NONE | |
TARGET = ('67.205.133.224', 443) |
To run this benchmark, clone this gist, cd
into the directory, and then run tox
. This will print a set of results.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
A script that takes a path to a given cert and key and rebuilds them in new | |
files. | |
""" | |
import sys | |
from cryptography import x509 | |
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat.primitives import hashes, serialization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyConnectionPool(HTTPSConnectionPool): | |
# This does not affect the value of HTTPSConnectionPool.ConnectionCls | |
ConnectionCls = Whatever | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copyright (c) 2017 Cory Benfield | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all |